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;
using nagai = long long;
#define sz(x) int((x).size())
const int N=3003;
string ss[N];
int cri[N][N],cdo[N][N];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n,m;
cin>>n>>m;
for(int i=0;i<n;++i)cin>>ss[i];
for(int i=0;i<n;++i)
for(int j=m-1;j>=0;j--)
if(j==m-1)cri[i][j]=(ss[i][j]=='O');else cri[i][j]=(ss[i][j]=='O')+cri[i][j+1];
nagai ans=0;
for(int i=n-1;i>=0;--i)
for(int j=0;j<m;++j){
if(i==n-1)cdo[i][j]=(ss[i][j]=='I');else cdo[i][j]=(ss[i][j]=='I')+cdo[i+1][j];
if(ss[i][j]=='J')
ans+=cdo[i][j]*cri[i][j];
}
cout<<ans<<'\n';
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... |