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;
int x,y,n,m,i,j,dp1[3005][3005],dp2[3005][3005];
ll ans;
char s[3005][3005];
int main(){
cin >> n >> m;
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
cin >> s[i][j];
}
}
for(i=n;i>0;i--){
for(j=m;j>0;j--){
dp1[i][j]=dp1[i][j+1];
dp2[i][j]=dp2[i+1][j];
if(s[i][j]=='J') ans+=dp1[i][j]*dp2[i][j];
if(s[i][j]=='O') dp1[i][j]++;
if(s[i][j]=='I') dp2[i][j]++;
}
}
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... |