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;
int main(){
int h,w;cin>>h>>w;
int pso[h+1][w+1];
int psi[h+1][w+1];
for(int i=0; i<=h; i++){
pso[i][0]=0;
}
for(int i=0; i<=w; i++){
pso[0][i]=0;
}
string s[h];
for(int i=0; i<h; i++)cin>>s[i];
for(int i=1; i<=h; i++){
for(int j=1; j<=w; j++){
psi[i][j]=psi[i-1][j];
pso[i][j]=pso[i][j-1];
if(s[i-1][j-1]=='I')psi[i][j]++;
if(s[i-1][j-1]=='O')pso[i][j]++;
}
}
int ans=0;
for(int i=1; i<=h; i++){
for(int j=1; j<=w; j++){
if(s[i-1][j-1]=='J'){
int m = psi[h][j]-psi[i][j];
int n = pso[i][w]-pso[i][j];
ans+=m*n;
}
}
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |