/**
____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int N, M;
cin >> N >> M;
char mat[N][M];
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
cin >> mat[i][j];
}
}
int R[N][M];
for (int i = 0; i < N; i++) {
for (int j = M - 1, curr = 0; j >= 0; j--) {
curr += (mat[i][j] == 'O');
R[i][j] = (mat[i][j] == 'J' ? curr : 0);
}
}
ll answer = 0;
for (int j = 0; j < M; j++) {
for (int i = 0, curr = 0; i < N; i++) {
curr += R[i][j];
if (mat[i][j] == 'I') {
answer += curr;
}
}
}
cout << answer << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
5 ms |
1364 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
3 ms |
1064 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
1700 KB |
Output is correct |
19 |
Correct |
4 ms |
1616 KB |
Output is correct |
20 |
Correct |
5 ms |
1748 KB |
Output is correct |
21 |
Correct |
6 ms |
1708 KB |
Output is correct |
22 |
Correct |
5 ms |
1620 KB |
Output is correct |
23 |
Correct |
5 ms |
1688 KB |
Output is correct |
24 |
Correct |
5 ms |
1700 KB |
Output is correct |
25 |
Correct |
4 ms |
1620 KB |
Output is correct |
26 |
Correct |
4 ms |
1748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
5 ms |
1364 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
3 ms |
1064 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
1700 KB |
Output is correct |
19 |
Correct |
4 ms |
1616 KB |
Output is correct |
20 |
Correct |
5 ms |
1748 KB |
Output is correct |
21 |
Correct |
6 ms |
1708 KB |
Output is correct |
22 |
Correct |
5 ms |
1620 KB |
Output is correct |
23 |
Correct |
5 ms |
1688 KB |
Output is correct |
24 |
Correct |
5 ms |
1700 KB |
Output is correct |
25 |
Correct |
4 ms |
1620 KB |
Output is correct |
26 |
Correct |
4 ms |
1748 KB |
Output is correct |
27 |
Correct |
244 ms |
50176 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
12 ms |
4044 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
163 ms |
36976 KB |
Output is correct |
32 |
Correct |
255 ms |
52800 KB |
Output is correct |
33 |
Correct |
239 ms |
52944 KB |
Output is correct |
34 |
Correct |
190 ms |
42956 KB |
Output is correct |
35 |
Correct |
264 ms |
52688 KB |
Output is correct |
36 |
Correct |
225 ms |
52944 KB |
Output is correct |
37 |
Correct |
244 ms |
53124 KB |
Output is correct |
38 |
Correct |
168 ms |
36684 KB |
Output is correct |
39 |
Correct |
165 ms |
36812 KB |
Output is correct |