이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pll pair<int, int>
#define pb push_back
#define fi first
#define se second
using namespace std;
const int MX=3005;
int h, w, prefr[MX][MX], prefc[MX][MX];
ll ans;
char g[MX][MX];
int main(){
cin >> h >> w;
vector<pll> start;
for(int i=1; i<=h; i++){
for(int j=1; j<=w; j++){
cin >> g[i][j];
if(g[i][j]=='J') start.pb({i, j});
prefr[i][j]=prefr[i][j-1];
prefc[j][i]=prefc[j][i-1];
if(g[i][j]=='O') prefr[i][j]++;
if(g[i][j]=='I') prefc[j][i]++;
}
}
for(auto i : start){
int r=i.fi, c=i.se;
// cout << r << " " << c << endl;
int oo=(prefr[r][w]-prefr[r][c]);
int ii=(prefc[c][h]-prefc[c][r]);
// cout << "nilai " << ii << " " << oo << endl;
ans+=ii*oo;
}
cout << ans << endl;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |