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;
#define int long long
int co[3005][3005], ci[3005][3005];
char gr[3005][3005];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m; cin>>n>>m;
for(int i=0; i < n; i++){
for(int l=0; l < m; l++){
cin >> gr[i][l];
if(gr[i][l] == 'I'){
ci[i][l]++;
}
if(gr[i][l] == 'O'){
co[i][l]++;
}
}
}
for(int i=0; i<n; i++){
for(int l=m-2; l>=0; l--){
co[i][l]+=co[i][l+1];
}
}
for(int i=n-2; i>=0; i--){
for(int l=0; l<m; l++){
ci[i][l]+=ci[i+1][l];
}
}
int ans=0;
for(int i=0; i<n; i++){
for(int l=0; l<m; l++){
if(gr[i][l]=='J') ans+=(co[i][l]*ci[i][l]);
}
}
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... |