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;
string gr[N];
int co[N][N];
int main()
{
cin >> n >> m;
for(int i=0;i<n;i++) cin >> gr[i];
for(int i=n-1;i>=0;i--)
{
for(int j=0;j<m;j++)
{
co[i][j]=(gr[i][j]=='I')+co[i+1][j];
}
}
long long ans=0;
for(int i=0;i<n;i++)
{
int cur=0;
for(int j=m-1;j>=0;j--)
{
cur+=gr[i][j]=='O';
if(gr[i][j]=='J')
{
ans+=1LL*cur*co[i][j];
}
}
}
printf("%lld\n", 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... |