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 maxN = 3023;
int H, W;
char grid[maxN][maxN];
int O[maxN][maxN], I[maxN][maxN];
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> H >> W;
for (int i = 1; i <= H; i++) {
for (int j = 1; j <= W; j++) {
cin >> grid[i][j];
}
}
for (int i = 1; i <= H; i++) {
for (int j = W; j >= 1; j--) {
O[i][j] = O[i][j+1] + (grid[i][j] == 'O');
}
}
for (int j = 1; j <= W; j++) {
for (int i = H; i >= 1; i--) {
I[i][j] = I[i+1][j] + (grid[i][j] == 'I');
}
}
long long ans = 0;
for (int i = 1; i <= H; i++) {
for (int j = 1; j <= W; j++) {
if (grid[i][j] == 'J') {
ans += 1ll * O[i][j] * I[i][j];
}
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |