n, m = map(int,input().split())
v = []
for i in range(n):
s = input()
v += [s]
cnt_o = [[0 for i in range(m + 1)]for i in range(n + 1)]
cnt_i = [[0 for i in range(n + 1)]for i in range(m + 1)]
for i in range(n):
x = 0
for j in range(m):
if v[i][j] == 'O':
x += 1
cnt_o[i][j] = x
for i in range(m):
for j in range(n):
ok = 0
if v[j][i] == 'I':ok = 1
cnt_i[i][j] = cnt_i[i][j - 1] + ok
ans =0
for i in range(n):
for j in range(m):
if v[i][j] == 'J':
# print(i,j)
x = cnt_o[i][m - 1] - cnt_o[i][j]
y = cnt_i[j][n - 1] - cnt_i[j][i]
# print(x,y)
ans += x * y
print(ans)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
18196 KB |
Output is correct |
2 |
Correct |
30 ms |
18200 KB |
Output is correct |
3 |
Correct |
36 ms |
18216 KB |
Output is correct |
4 |
Correct |
28 ms |
18140 KB |
Output is correct |
5 |
Correct |
47 ms |
20492 KB |
Output is correct |
6 |
Correct |
51 ms |
20544 KB |
Output is correct |
7 |
Correct |
50 ms |
20264 KB |
Output is correct |
8 |
Correct |
44 ms |
19984 KB |
Output is correct |
9 |
Correct |
51 ms |
20376 KB |
Output is correct |
10 |
Correct |
50 ms |
20244 KB |
Output is correct |
11 |
Correct |
47 ms |
20220 KB |
Output is correct |
12 |
Correct |
66 ms |
20204 KB |
Output is correct |
13 |
Correct |
53 ms |
20236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
18196 KB |
Output is correct |
2 |
Correct |
30 ms |
18200 KB |
Output is correct |
3 |
Correct |
36 ms |
18216 KB |
Output is correct |
4 |
Correct |
28 ms |
18140 KB |
Output is correct |
5 |
Correct |
47 ms |
20492 KB |
Output is correct |
6 |
Correct |
51 ms |
20544 KB |
Output is correct |
7 |
Correct |
50 ms |
20264 KB |
Output is correct |
8 |
Correct |
44 ms |
19984 KB |
Output is correct |
9 |
Correct |
51 ms |
20376 KB |
Output is correct |
10 |
Correct |
50 ms |
20244 KB |
Output is correct |
11 |
Correct |
47 ms |
20220 KB |
Output is correct |
12 |
Correct |
66 ms |
20204 KB |
Output is correct |
13 |
Correct |
53 ms |
20236 KB |
Output is correct |
14 |
Correct |
65 ms |
23084 KB |
Output is correct |
15 |
Correct |
53 ms |
19904 KB |
Output is correct |
16 |
Correct |
73 ms |
22724 KB |
Output is correct |
17 |
Correct |
41 ms |
19524 KB |
Output is correct |
18 |
Correct |
67 ms |
24500 KB |
Output is correct |
19 |
Correct |
96 ms |
24328 KB |
Output is correct |
20 |
Correct |
80 ms |
25000 KB |
Output is correct |
21 |
Correct |
72 ms |
25096 KB |
Output is correct |
22 |
Correct |
67 ms |
24056 KB |
Output is correct |
23 |
Correct |
72 ms |
25080 KB |
Output is correct |
24 |
Correct |
70 ms |
24716 KB |
Output is correct |
25 |
Correct |
70 ms |
24484 KB |
Output is correct |
26 |
Correct |
78 ms |
24988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
18196 KB |
Output is correct |
2 |
Correct |
30 ms |
18200 KB |
Output is correct |
3 |
Correct |
36 ms |
18216 KB |
Output is correct |
4 |
Correct |
28 ms |
18140 KB |
Output is correct |
5 |
Correct |
47 ms |
20492 KB |
Output is correct |
6 |
Correct |
51 ms |
20544 KB |
Output is correct |
7 |
Correct |
50 ms |
20264 KB |
Output is correct |
8 |
Correct |
44 ms |
19984 KB |
Output is correct |
9 |
Correct |
51 ms |
20376 KB |
Output is correct |
10 |
Correct |
50 ms |
20244 KB |
Output is correct |
11 |
Correct |
47 ms |
20220 KB |
Output is correct |
12 |
Correct |
66 ms |
20204 KB |
Output is correct |
13 |
Correct |
53 ms |
20236 KB |
Output is correct |
14 |
Correct |
65 ms |
23084 KB |
Output is correct |
15 |
Correct |
53 ms |
19904 KB |
Output is correct |
16 |
Correct |
73 ms |
22724 KB |
Output is correct |
17 |
Correct |
41 ms |
19524 KB |
Output is correct |
18 |
Correct |
67 ms |
24500 KB |
Output is correct |
19 |
Correct |
96 ms |
24328 KB |
Output is correct |
20 |
Correct |
80 ms |
25000 KB |
Output is correct |
21 |
Correct |
72 ms |
25096 KB |
Output is correct |
22 |
Correct |
67 ms |
24056 KB |
Output is correct |
23 |
Correct |
72 ms |
25080 KB |
Output is correct |
24 |
Correct |
70 ms |
24716 KB |
Output is correct |
25 |
Correct |
70 ms |
24484 KB |
Output is correct |
26 |
Correct |
78 ms |
24988 KB |
Output is correct |
27 |
Correct |
641 ms |
171412 KB |
Output is correct |
28 |
Correct |
99 ms |
24856 KB |
Output is correct |
29 |
Correct |
97 ms |
32384 KB |
Output is correct |
30 |
Correct |
51 ms |
20796 KB |
Output is correct |
31 |
Correct |
492 ms |
132048 KB |
Output is correct |
32 |
Correct |
542 ms |
180248 KB |
Output is correct |
33 |
Correct |
552 ms |
180476 KB |
Output is correct |
34 |
Correct |
534 ms |
149552 KB |
Output is correct |
35 |
Correct |
597 ms |
180240 KB |
Output is correct |
36 |
Correct |
535 ms |
180560 KB |
Output is correct |
37 |
Correct |
704 ms |
180436 KB |
Output is correct |
38 |
Correct |
402 ms |
132064 KB |
Output is correct |
39 |
Correct |
421 ms |
132328 KB |
Output is correct |