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 ll long long
const int mxn=3e3+5;
int n,m;
string s;
char c[mxn][mxn];
int rast[mxn][mxn],pain[mxn][mxn];
ll ans;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>s;
for(int j=0;j<m;j++)
c[i][j]=s[j];
}
for(int i=n-1;i>=0;i--){
for(int j=m-1;j>=0;j--){
if(i!=n-1)pain[i][j]=pain[i+1][j]+(c[i+1][j]=='I');
if(j!=m-1)rast[i][j]=rast[i][j+1]+(c[i][j+1]=='O');
if(c[i][j]=='J')ans+=(ll)pain[i][j]*rast[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... |