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 ll long long
using namespace std;
char arr[3002][3002];
int O[3002][3002], I[3002][3002];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int N, M;
cin>>N>>M;
for(int i=1;i<=N;i++) {
for(int k=1;k<=M;k++) {
cin>>arr[i][k];
}
}
for(int i=1;i<=N;i++) {
for(int k=M;k>=1;k--) {
O[i][k] = O[i][k + 1];
if(arr[i][k] == 'O') O[i][k]++;
}
}
for(int i=1;i<=M;i++) {
for(int k=N;k>=1;k--) {
I[k][i] = I[k+1][i];
if(arr[k][i] == 'I') I[k][i]++;
}
}
ll ans = 0ll;
for(int i=1;i<=N;i++) {
for(int k=1;k<=M;k++) {
if(arr[i][k] != 'J') continue;
ans += 1ll * O[i][k] * 1ll * I[i][k];
// cout<<i<<" "<<k<<" "<<O[i][k]<<" "<<I[i][k]<<endl;
}
}
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... |