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 MAXN 3010
using namespace std;
int h, w, qorb[MAXN][MAXN], qing[MAXN][MAXN];
char s[MAXN][MAXN];
int main()
{
cin >> h >> w;
for(int i = 1 ; i <= h ; i++)
{
for(int j = 1 ; j <= w ; j++)
{
cin >> s[i][j];
qorb[i][j] = qorb[i][j-1];
if(s[i][j] == 'O') qorb[i][j]++;
}
}
for(int j = 1 ; j <= w ; j++)
{
for(int i = 1 ; i <= h ; i++)
{
qing[i][j] = qing[i-1][j];
if(s[i][j] == 'I') qing[i][j]++;
}
}
long long int sum = 0;
for(int i = 1 ; i <= h ; i++)
{
for(int j = 1 ; j <= w ; j++)
{
if(s[i][j] == 'J')
{
long long int v = (qorb[i][w] - qorb[i][j])*(qing[h][j] - qing[i][j]);
sum += v;
}
}
}
cout << sum << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |