#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];
}
int64_t 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');
}
}
int64_t 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');
}
}
int64_t ans = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (arr[i][j] && x[j] && o[i]) {
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 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
7 ms |
3540 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
5 ms |
2516 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
9 ms |
4616 KB |
Output is correct |
19 |
Correct |
8 ms |
4308 KB |
Output is correct |
20 |
Correct |
9 ms |
4624 KB |
Output is correct |
21 |
Correct |
9 ms |
4916 KB |
Output is correct |
22 |
Correct |
9 ms |
4536 KB |
Output is correct |
23 |
Correct |
9 ms |
4820 KB |
Output is correct |
24 |
Correct |
9 ms |
4860 KB |
Output is correct |
25 |
Correct |
10 ms |
4500 KB |
Output is correct |
26 |
Correct |
9 ms |
4792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
7 ms |
3540 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
5 ms |
2516 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
9 ms |
4616 KB |
Output is correct |
19 |
Correct |
8 ms |
4308 KB |
Output is correct |
20 |
Correct |
9 ms |
4624 KB |
Output is correct |
21 |
Correct |
9 ms |
4916 KB |
Output is correct |
22 |
Correct |
9 ms |
4536 KB |
Output is correct |
23 |
Correct |
9 ms |
4820 KB |
Output is correct |
24 |
Correct |
9 ms |
4860 KB |
Output is correct |
25 |
Correct |
10 ms |
4500 KB |
Output is correct |
26 |
Correct |
9 ms |
4792 KB |
Output is correct |
27 |
Correct |
487 ms |
153088 KB |
Output is correct |
28 |
Correct |
2 ms |
700 KB |
Output is correct |
29 |
Correct |
25 ms |
12056 KB |
Output is correct |
30 |
Correct |
1 ms |
724 KB |
Output is correct |
31 |
Correct |
325 ms |
113776 KB |
Output is correct |
32 |
Correct |
513 ms |
160436 KB |
Output is correct |
33 |
Correct |
501 ms |
160892 KB |
Output is correct |
34 |
Correct |
401 ms |
131944 KB |
Output is correct |
35 |
Correct |
496 ms |
160456 KB |
Output is correct |
36 |
Correct |
496 ms |
160904 KB |
Output is correct |
37 |
Correct |
475 ms |
161432 KB |
Output is correct |
38 |
Correct |
342 ms |
112952 KB |
Output is correct |
39 |
Correct |
345 ms |
113444 KB |
Output is correct |