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 int long long int
int n,m;
string s[3005];
int suff_o[3005][3005];
int suff_i[3005][3005];
int sum;
int32_t main()
{
cin >> n >> m;
for(int i=0;i<n;i++)
cin >> s[i];
for(int i=0;i<n;i++)
{
for(int j=m-1;j>=0;j--)
{
suff_o[i][j]=suff_o[i][j+1];
if(s[i][j]=='O') suff_o[i][j]++;
}
}
for(int i=0;i<m;i++)
{
for(int j=n-1;j>=0;j--)
{
suff_i[j][i]=suff_i[j+1][i];
if(s[j][i]=='I') suff_i[j][i]++;
}
}
sum=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(s[i][j]=='J')
{
sum+=(suff_i[i][j])*(suff_o[i][j]);
}
}
}
cout << sum;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |