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 MxN = 3005;
int n , m , d[MxN][MxN] , r[MxN][MxN];
long long ans;
char grid[MxN][MxN];
int main()
{
cin >> n >> m;
for(int i=1 ; i<=n ; i++)for(int j=1 ; j<=m ; j++)cin >> grid[i][j];
for(int i=n ; i>=1 ; i--)for(int j=1 ; j<=m ; j++)d[i][j] = d[i+1][j] + (grid[i][j]=='I');
for(int i=1 ; i<=n ; i++)for(int j=m ; j>=1 ; j--)r[i][j] = r[i][j+1] + (grid[i][j]=='O');
for(int i=1 ; i<=n ; i++)for(int j=1 ; j<=m ; j++)if(grid[i][j]=='J')ans+=d[i][j]*r[i][j];
cout << ans;
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... |