#include <bits/stdc++.h>
using namespace std;
int main() {
int H, W;
cin >> H >> W;
string arr[H];
for (int i = 0; i < H; i++) {
cin >> arr[i];
}
int o[H][W + 1];
for (int i = 0; i < H; i++) {
o[i][0] = 0;
for (int j = 0; j < W; j++) {
o[i][j + 1] = o[i][j] + (arr[i][j] == 'O');
}
}
int x[W][H + 1];
for (int i = 0; i < W; i++) {
x[i][0] = 0;
for (int j = 0; j < H; j++) {
x[i][j + 1] = x[i][j] + (arr[j][i] == 'I');
}
}
int ans = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (arr[i][j] && x[j] && o[i]) {
cout << i << " " << j << '\n';
assert(o[i][W] >= o[i][j]);
ans += (arr[i][j] == 'J') * (o[i][W] - o[i][j]) * (x[j][H] - x[j][i]);
}
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |