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>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long llong;
int h, w;
char grid[3000][3001];
int Ocnt[3001][3001];
int Icnt[3001][3001];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> h >> w;
for (int i = 0; i < h; ++i) {
cin >> grid[i];
}
for (int i = h; i--; ) {
for (int j = w; j--; ) {
Ocnt[i][j] = Ocnt[i][j + 1];
Icnt[i][j] = Icnt[i + 1][j];
if (grid[i][j] == 'O') ++Ocnt[i][j];
if (grid[i][j] == 'I') ++Icnt[i][j];
}
}
llong ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (grid[i][j] == 'J') ans += Ocnt[i][j] * Icnt[i][j];
}
}
printf("%lld\n", 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... |