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 <iostream>
using namespace std;
int h, w;
char S[3010][3010];
int O[3010][3010], I[3010][3010];
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>h>>w;
for(int i=0; i<h; i++) cin>>S[i];
for(int i=0; i<h; i++) for(int j=w-1; j>=0; j--)
O[i][j] = O[i][j+1] + (S[i][j]=='O');
for(int j=0; j<w; j++) for(int i=h-1; i>=0; i--)
I[i][j] = I[i+1][j] + (S[i][j]=='I');
long long ans = 0;
for(int i=0; i<h; i++) for(int j=0; j<w; j++)
ans += 1LL*(S[i][j]=='J') * O[i][j] * I[i][j];
cout<<ans<<'\n';
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... |