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 |
13 ms |
2900 KB |
Output is correct |
2 |
Correct |
15 ms |
2844 KB |
Output is correct |
3 |
Correct |
13 ms |
2840 KB |
Output is correct |
4 |
Correct |
13 ms |
2856 KB |
Output is correct |
5 |
Correct |
28 ms |
3156 KB |
Output is correct |
6 |
Correct |
27 ms |
3028 KB |
Output is correct |
7 |
Correct |
27 ms |
3028 KB |
Output is correct |
8 |
Correct |
29 ms |
3104 KB |
Output is correct |
9 |
Correct |
28 ms |
3028 KB |
Output is correct |
10 |
Correct |
28 ms |
3128 KB |
Output is correct |
11 |
Correct |
32 ms |
3160 KB |
Output is correct |
12 |
Correct |
27 ms |
3104 KB |
Output is correct |
13 |
Correct |
31 ms |
3028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
2900 KB |
Output is correct |
2 |
Correct |
15 ms |
2844 KB |
Output is correct |
3 |
Correct |
13 ms |
2840 KB |
Output is correct |
4 |
Correct |
13 ms |
2856 KB |
Output is correct |
5 |
Correct |
28 ms |
3156 KB |
Output is correct |
6 |
Correct |
27 ms |
3028 KB |
Output is correct |
7 |
Correct |
27 ms |
3028 KB |
Output is correct |
8 |
Correct |
29 ms |
3104 KB |
Output is correct |
9 |
Correct |
28 ms |
3028 KB |
Output is correct |
10 |
Correct |
28 ms |
3128 KB |
Output is correct |
11 |
Correct |
32 ms |
3160 KB |
Output is correct |
12 |
Correct |
27 ms |
3104 KB |
Output is correct |
13 |
Correct |
31 ms |
3028 KB |
Output is correct |
14 |
Correct |
313 ms |
7676 KB |
Output is correct |
15 |
Correct |
23 ms |
3124 KB |
Output is correct |
16 |
Correct |
207 ms |
6316 KB |
Output is correct |
17 |
Correct |
19 ms |
2976 KB |
Output is correct |
18 |
Correct |
391 ms |
9068 KB |
Output is correct |
19 |
Correct |
353 ms |
10508 KB |
Output is correct |
20 |
Correct |
407 ms |
8948 KB |
Output is correct |
21 |
Correct |
419 ms |
9176 KB |
Output is correct |
22 |
Correct |
387 ms |
9784 KB |
Output is correct |
23 |
Correct |
391 ms |
8944 KB |
Output is correct |
24 |
Correct |
413 ms |
9164 KB |
Output is correct |
25 |
Correct |
348 ms |
11036 KB |
Output is correct |
26 |
Correct |
394 ms |
8936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
2900 KB |
Output is correct |
2 |
Correct |
15 ms |
2844 KB |
Output is correct |
3 |
Correct |
13 ms |
2840 KB |
Output is correct |
4 |
Correct |
13 ms |
2856 KB |
Output is correct |
5 |
Correct |
28 ms |
3156 KB |
Output is correct |
6 |
Correct |
27 ms |
3028 KB |
Output is correct |
7 |
Correct |
27 ms |
3028 KB |
Output is correct |
8 |
Correct |
29 ms |
3104 KB |
Output is correct |
9 |
Correct |
28 ms |
3028 KB |
Output is correct |
10 |
Correct |
28 ms |
3128 KB |
Output is correct |
11 |
Correct |
32 ms |
3160 KB |
Output is correct |
12 |
Correct |
27 ms |
3104 KB |
Output is correct |
13 |
Correct |
31 ms |
3028 KB |
Output is correct |
14 |
Correct |
313 ms |
7676 KB |
Output is correct |
15 |
Correct |
23 ms |
3124 KB |
Output is correct |
16 |
Correct |
207 ms |
6316 KB |
Output is correct |
17 |
Correct |
19 ms |
2976 KB |
Output is correct |
18 |
Correct |
391 ms |
9068 KB |
Output is correct |
19 |
Correct |
353 ms |
10508 KB |
Output is correct |
20 |
Correct |
407 ms |
8948 KB |
Output is correct |
21 |
Correct |
419 ms |
9176 KB |
Output is correct |
22 |
Correct |
387 ms |
9784 KB |
Output is correct |
23 |
Correct |
391 ms |
8944 KB |
Output is correct |
24 |
Correct |
413 ms |
9164 KB |
Output is correct |
25 |
Correct |
348 ms |
11036 KB |
Output is correct |
26 |
Correct |
394 ms |
8936 KB |
Output is correct |
27 |
Execution timed out |
1104 ms |
219820 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |