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 long long mod=1e9+7;
int n,m,ans,orb[3050][3050],ing[3050][3050];
char c[3050][3050];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>m;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>c[i][j];
if(c[i][j]=='I')ing[i][j]++;
else if(c[i][j]=='O') orb[i][j]++;
}
}
for(int i=0;i<n;i++)
{
for(int j=m-1;j>=0;j--)orb[i][j]+=orb[i][j+1];
}
for(int i=0;i<m;i++)
{
for(int j=n-1;j>=0;j--)ing[j][i]+=ing[j+1][i];
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(c[i][j]=='J')ans+=ing[i][j]*orb[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... |