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>
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int nmax = 3e3 + 2;
long long o[nmax][nmax], I[nmax][nmax], h, w, ans;
string s[nmax];
int main(){
faster
cin >> h >> w;
for(int i = 1; i <= h; i++){
cin >> s[i];
s[i] = " " + s[i];
}
for(int i = h; i >= 1; i--){
for(int j = w; j >= 1; j--){
o[i][j] = o[i][j + 1] + (s[i][j] == 'O');
I[i][j] = I[i + 1][j] + (s[i][j] == 'I');
if(s[i][j] == 'J')ans += o[i][j]*I[i][j];
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |