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>
#define MAX 3010
#define ll long long
using namespace std;
int n, m;
ll ans;
ll PO[MAX][MAX];
ll PI[MAX][MAX];
char v[MAX][MAX];
int main()
{
cin >> n >> m ;
for(int g = 1 ; g <= n ; g++)
for(int h = 1 ; h <= m ; h++)
cin >> v[g][h];
for(int g = 1 ; g <= n ; g++)
for(int h = m ; h > 0 ; h--)
PO[g][h] = PO[g][h + 1] + (v[g][h] == 'O') ;
for(int g = n ; g > 0 ; g--)
for(int h = 1 ; h <= m ; h++)
PI[g][h] = PI[g + 1][h] + (v[g][h] == 'I') ;
for(int g = 1 ; g <= n ; g++)
for(int h = 1 ; h <= m ; h++)
if(v[g][h] == 'J')
ans += PO[g][h] * PI[g][h];
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... |