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 <iostream>
using namespace std;
using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
int const nmax = 3000;
char v[1 + nmax][1 + nmax];
int ingots[1 + nmax][1 + nmax], orbs[1 + nmax][1 + nmax];
int main()
{
int n, m;
cin >> n >> m;
for(int i = 1;i <= n; i++)
for(int j = 1;j <= m; j++) {
cin >> v[i][j];
if(v[i][j] == 'O')
orbs[i][j]++;
else if(v[i][j] == 'I')
ingots[i][j]++;
}
for(int i = n; 1 <= i; i--)
for(int j = m; 1 <= j; j--) {
orbs[i][j] += orbs[i][j + 1];
ingots[i][j] += ingots[i + 1][j];
}
ll result = 0;
for(int i = 1;i <= n; i++)
for(int j = 1;j <= m; j++)
if(v[i][j] == 'J') {
result += orbs[i][j] * ingots[i][j];
}
cout << result << '\n';
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... |