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;
string s[3010];
long long oo[3010][3010];
long long ii[3010][3010];
int main(){
int n;
int m;
long long sumi=0;
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>s[i];
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(i==0)
ii[i][j]=0;
if(j==0)
oo[i][j]=0;
if(s[i][j]=='O')
oo[i][j]=oo[i][j-1]+1;
else
oo[i][j]=oo[i][j-1];
if(s[i][j]=='I')
ii[i][j]=ii[i-1][j]+1;
else
ii[i][j]=ii[i-1][j];
}
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(s[i][j]=='J'){
sumi+=(ii[n-1][j]-ii[i][j])*(oo[i][m-1]-oo[i][j]);
}
}
}
cout<<sumi;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |