h,w = map(int, input().split())
grid = [list(input()) for i in range(h)]
prefx = [[0 for i in range(w)]for i in range(h)]
prefy = [[0 for i in range(w)]for i in range(h)]
for i in range(h):
for j in range(w):
if j==0:
if grid[i][j] == "O":
prefx[i][j] = 1
else:
prefx[i][j] = prefx[i][j-1] + bool(grid[i][j] == "O")
for i in range(h):
for j in range(w):
if i==0:
if grid[i][j] == "I":
prefy[i][j] = 1
else:
prefy[i][j] = prefy[i-1][j] + bool(grid[i][j] == "I")
ans = 0
for i in range(h):
for j in range(w):
if grid[i][j] == "J":
ans += (prefx[i][w-1] - prefx[i][j])*(prefy[h-1][j] - prefy[i][j])
print(ans)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
18232 KB |
Output is correct |
2 |
Correct |
33 ms |
18244 KB |
Output is correct |
3 |
Correct |
33 ms |
18140 KB |
Output is correct |
4 |
Correct |
34 ms |
18172 KB |
Output is correct |
5 |
Correct |
57 ms |
20380 KB |
Output is correct |
6 |
Correct |
62 ms |
21088 KB |
Output is correct |
7 |
Correct |
60 ms |
20612 KB |
Output is correct |
8 |
Correct |
58 ms |
19952 KB |
Output is correct |
9 |
Correct |
60 ms |
20848 KB |
Output is correct |
10 |
Correct |
59 ms |
20512 KB |
Output is correct |
11 |
Correct |
57 ms |
20400 KB |
Output is correct |
12 |
Correct |
59 ms |
21284 KB |
Output is correct |
13 |
Correct |
61 ms |
20504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
18232 KB |
Output is correct |
2 |
Correct |
33 ms |
18244 KB |
Output is correct |
3 |
Correct |
33 ms |
18140 KB |
Output is correct |
4 |
Correct |
34 ms |
18172 KB |
Output is correct |
5 |
Correct |
57 ms |
20380 KB |
Output is correct |
6 |
Correct |
62 ms |
21088 KB |
Output is correct |
7 |
Correct |
60 ms |
20612 KB |
Output is correct |
8 |
Correct |
58 ms |
19952 KB |
Output is correct |
9 |
Correct |
60 ms |
20848 KB |
Output is correct |
10 |
Correct |
59 ms |
20512 KB |
Output is correct |
11 |
Correct |
57 ms |
20400 KB |
Output is correct |
12 |
Correct |
59 ms |
21284 KB |
Output is correct |
13 |
Correct |
61 ms |
20504 KB |
Output is correct |
14 |
Correct |
106 ms |
30684 KB |
Output is correct |
15 |
Correct |
75 ms |
20756 KB |
Output is correct |
16 |
Correct |
88 ms |
27240 KB |
Output is correct |
17 |
Correct |
54 ms |
19424 KB |
Output is correct |
18 |
Correct |
126 ms |
34084 KB |
Output is correct |
19 |
Correct |
116 ms |
33600 KB |
Output is correct |
20 |
Correct |
113 ms |
33796 KB |
Output is correct |
21 |
Correct |
117 ms |
34088 KB |
Output is correct |
22 |
Correct |
113 ms |
33872 KB |
Output is correct |
23 |
Correct |
110 ms |
33848 KB |
Output is correct |
24 |
Correct |
113 ms |
33844 KB |
Output is correct |
25 |
Correct |
117 ms |
33836 KB |
Output is correct |
26 |
Correct |
113 ms |
33872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
18232 KB |
Output is correct |
2 |
Correct |
33 ms |
18244 KB |
Output is correct |
3 |
Correct |
33 ms |
18140 KB |
Output is correct |
4 |
Correct |
34 ms |
18172 KB |
Output is correct |
5 |
Correct |
57 ms |
20380 KB |
Output is correct |
6 |
Correct |
62 ms |
21088 KB |
Output is correct |
7 |
Correct |
60 ms |
20612 KB |
Output is correct |
8 |
Correct |
58 ms |
19952 KB |
Output is correct |
9 |
Correct |
60 ms |
20848 KB |
Output is correct |
10 |
Correct |
59 ms |
20512 KB |
Output is correct |
11 |
Correct |
57 ms |
20400 KB |
Output is correct |
12 |
Correct |
59 ms |
21284 KB |
Output is correct |
13 |
Correct |
61 ms |
20504 KB |
Output is correct |
14 |
Correct |
106 ms |
30684 KB |
Output is correct |
15 |
Correct |
75 ms |
20756 KB |
Output is correct |
16 |
Correct |
88 ms |
27240 KB |
Output is correct |
17 |
Correct |
54 ms |
19424 KB |
Output is correct |
18 |
Correct |
126 ms |
34084 KB |
Output is correct |
19 |
Correct |
116 ms |
33600 KB |
Output is correct |
20 |
Correct |
113 ms |
33796 KB |
Output is correct |
21 |
Correct |
117 ms |
34088 KB |
Output is correct |
22 |
Correct |
113 ms |
33872 KB |
Output is correct |
23 |
Correct |
110 ms |
33848 KB |
Output is correct |
24 |
Correct |
113 ms |
33844 KB |
Output is correct |
25 |
Correct |
117 ms |
33836 KB |
Output is correct |
26 |
Correct |
113 ms |
33872 KB |
Output is correct |
27 |
Runtime error |
674 ms |
274432 KB |
Execution killed with signal 9 |
28 |
Halted |
0 ms |
0 KB |
- |