H, W = map(int, input().split())
grid = []
for i in range(H):
grid.append(list(input()))
## grid[h][w]
grido = [[0 for i in range(W+1)] for j in range(H+1)] ## rows
gridi = [[0 for i in range(W+1)] for j in range(H+1)] ## cols
## o
for row in range(H):
for col in range(W-1, -1, -1):
num = (grid[row][col] == "O")
grido[row][col] = grido[row][col+1] + num
## i
for col in range(W):
for row in range(H-1, -1, -1):
num = (grid[row][col] == "I")
gridi[row][col] = gridi[row+1][col] + num
ans = 0
for row in range(H):
for col in range(W):
if grid[row][col] == "J":
ans += grido[row][col+1] * gridi[row+1][col]
print(ans)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
18160 KB |
Output is correct |
2 |
Correct |
29 ms |
18196 KB |
Output is correct |
3 |
Correct |
29 ms |
18220 KB |
Output is correct |
4 |
Correct |
30 ms |
18248 KB |
Output is correct |
5 |
Correct |
47 ms |
20640 KB |
Output is correct |
6 |
Correct |
46 ms |
20620 KB |
Output is correct |
7 |
Correct |
49 ms |
20176 KB |
Output is correct |
8 |
Correct |
51 ms |
20392 KB |
Output is correct |
9 |
Correct |
47 ms |
20692 KB |
Output is correct |
10 |
Correct |
44 ms |
20120 KB |
Output is correct |
11 |
Correct |
47 ms |
20444 KB |
Output is correct |
12 |
Correct |
47 ms |
20544 KB |
Output is correct |
13 |
Correct |
45 ms |
20104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
18160 KB |
Output is correct |
2 |
Correct |
29 ms |
18196 KB |
Output is correct |
3 |
Correct |
29 ms |
18220 KB |
Output is correct |
4 |
Correct |
30 ms |
18248 KB |
Output is correct |
5 |
Correct |
47 ms |
20640 KB |
Output is correct |
6 |
Correct |
46 ms |
20620 KB |
Output is correct |
7 |
Correct |
49 ms |
20176 KB |
Output is correct |
8 |
Correct |
51 ms |
20392 KB |
Output is correct |
9 |
Correct |
47 ms |
20692 KB |
Output is correct |
10 |
Correct |
44 ms |
20120 KB |
Output is correct |
11 |
Correct |
47 ms |
20444 KB |
Output is correct |
12 |
Correct |
47 ms |
20544 KB |
Output is correct |
13 |
Correct |
45 ms |
20104 KB |
Output is correct |
14 |
Correct |
90 ms |
30816 KB |
Output is correct |
15 |
Correct |
57 ms |
20168 KB |
Output is correct |
16 |
Correct |
71 ms |
27816 KB |
Output is correct |
17 |
Correct |
48 ms |
19916 KB |
Output is correct |
18 |
Correct |
93 ms |
34456 KB |
Output is correct |
19 |
Correct |
88 ms |
33680 KB |
Output is correct |
20 |
Correct |
89 ms |
34296 KB |
Output is correct |
21 |
Correct |
95 ms |
34340 KB |
Output is correct |
22 |
Correct |
91 ms |
33732 KB |
Output is correct |
23 |
Correct |
89 ms |
34308 KB |
Output is correct |
24 |
Correct |
93 ms |
34496 KB |
Output is correct |
25 |
Correct |
89 ms |
33448 KB |
Output is correct |
26 |
Correct |
88 ms |
34336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
18160 KB |
Output is correct |
2 |
Correct |
29 ms |
18196 KB |
Output is correct |
3 |
Correct |
29 ms |
18220 KB |
Output is correct |
4 |
Correct |
30 ms |
18248 KB |
Output is correct |
5 |
Correct |
47 ms |
20640 KB |
Output is correct |
6 |
Correct |
46 ms |
20620 KB |
Output is correct |
7 |
Correct |
49 ms |
20176 KB |
Output is correct |
8 |
Correct |
51 ms |
20392 KB |
Output is correct |
9 |
Correct |
47 ms |
20692 KB |
Output is correct |
10 |
Correct |
44 ms |
20120 KB |
Output is correct |
11 |
Correct |
47 ms |
20444 KB |
Output is correct |
12 |
Correct |
47 ms |
20544 KB |
Output is correct |
13 |
Correct |
45 ms |
20104 KB |
Output is correct |
14 |
Correct |
90 ms |
30816 KB |
Output is correct |
15 |
Correct |
57 ms |
20168 KB |
Output is correct |
16 |
Correct |
71 ms |
27816 KB |
Output is correct |
17 |
Correct |
48 ms |
19916 KB |
Output is correct |
18 |
Correct |
93 ms |
34456 KB |
Output is correct |
19 |
Correct |
88 ms |
33680 KB |
Output is correct |
20 |
Correct |
89 ms |
34296 KB |
Output is correct |
21 |
Correct |
95 ms |
34340 KB |
Output is correct |
22 |
Correct |
91 ms |
33732 KB |
Output is correct |
23 |
Correct |
89 ms |
34308 KB |
Output is correct |
24 |
Correct |
93 ms |
34496 KB |
Output is correct |
25 |
Correct |
89 ms |
33448 KB |
Output is correct |
26 |
Correct |
88 ms |
34336 KB |
Output is correct |
27 |
Runtime error |
505 ms |
274432 KB |
Execution killed with signal 9 |
28 |
Halted |
0 ms |
0 KB |
- |