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;
const int N = 3e3;
char v[N][N];
int cnt1[N][N];
int cnt2[N][N];
int main(){
int n,m;
cin>>n>>m;
for(int i = 0;i < n;i++){
for(int j = 0;j < m;j++){
cin>>v[i][j];
}
}
long long ans = 0;
for(int i = n - 1;i >= 0;i--){
for(int j = m - 1;j >= 0;j--){
cnt1[i][j] = (j == m - 1?0:cnt1[i][j + 1]) + (v[i][j] == 'O');
cnt2[i][j] = (i == n - 1?0:cnt2[i + 1][j]) + (v[i][j] == 'I');
if(v[i][j] == 'J')ans+=cnt1[i][j]*cnt2[i][j];
}
}
cout<<ans;
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... |