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;
const int N=3005;
int n,m,sRow[N][N][2],sCol[N][N][2];
char a[N][N];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>a[i][j];
for(int k=0;k<2;k++)
{
sRow[i][j][k]=sRow[i][j-1][k];
sCol[i][j][k]=sCol[i-1][j][k];
}
if(a[i][j]=='O') sRow[i][j][0]++,sCol[i][j][0]++;
if(a[i][j]=='I') sRow[i][j][1]++,sCol[i][j][1]++;
}
}
long long res=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(a[i][j]!='J') continue;
int numO=sRow[i][m][0]-sRow[i][j][0];
int numI=sCol[n][j][1]-sCol[i][j][1];
res+=1ll*numI*numO;
}
}
cout<<res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |