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;
typedef long long ll;
const int N = 3e3+45;
char a[N][N];
int cnti[N][N],cnto[N][N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int h,w;
cin >> h >> w;
for(int i = 1; i <= h; i++){
string s;
cin >> s;
for(int j = 1; j <= w; j++){
a[i][j] = s[j-1];
cnto[i][j] = cnto[i][j-1]+(a[i][j] == 'O');
}
}
for(int j = 1; j <= w; j++){
for(int i = 1; i <= h; i++){
cnti[j][i] = cnti[j][i-1]+(a[i][j] == 'I');
}
}
ll sol = 0;
for(int i = 1; i <= h; i++){
for(int j = 1; j <= w; j++){
if(a[i][j] != 'J'){
continue;
}
ll iovi = cnti[j][h]-cnti[j][i-1],oovi = cnto[i][w]-cnto[i][j-1];
sol += iovi*oovi;
}
}
cout << sol << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |