This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 3010;
char M[MAXN][MAXN];
int Os[MAXN][MAXN];
int Is[MAXN][MAXN];
int32_t main(){
int h, w; cin >> h >> w;
for(int i = 0; i < h; ++i){
for(int j = 0; j < w; ++j){
cin >> M[i][j];
}
}
for(int i = 0; i < h; ++i){
for(int j = w - 1; j >= 0; --j){
Os[i][j] = (M[i][j] == 'O');
if(j + 1 < w) Os[i][j] += Os[i][j + 1];
}
}
for(int j = 0; j < w; j++){
for(int i = h - 1; i >= 0; --i){
Is[i][j] = (M[i][j] == 'I');
if(i + 1 < h) Is[i][j] += Is[i + 1][j];
}
}
int ans = 0;
for(int i = 0; i < h; ++i){
for(int j = 0; j < w; ++j){
if(M[i][j] == 'J'){
int x = Is[i][j] * Os[i][j];
ans += x;
}
}
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |