#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int h, w;
cin >> h >> w;
vector<vector<char>> grid(h, vector<char>(w));
vector<vector<int>> mark(h, vector<int>(w));
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j)
cin >> grid[i][j];
}
int ok;
for (int j = 0; j < w; ++j) {
ok = 0;
for (int i = h - 1; i >= 0; --i) {
if (grid[i][j] == 'I')
ok++;
else if (grid[i][j] == 'J')
mark[i][j] = ok;
}
}
long long res = 0;
for (int i = 0; i < h; ++i) {
ok = 0;
for (int j = w - 1; j >= 0; --j) {
if (grid[i][j] == 'O')
ok++;
else if (grid[i][j] == 'J') {
mark[i][j] *= ok;
res += mark[i][j];
}
}
}
cout << res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 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 |
0 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 |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 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 |
0 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 |
340 KB |
Output is correct |
14 |
Correct |
6 ms |
1536 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
4 ms |
1104 KB |
Output is correct |
17 |
Correct |
1 ms |
324 KB |
Output is correct |
18 |
Correct |
9 ms |
1876 KB |
Output is correct |
19 |
Correct |
5 ms |
1736 KB |
Output is correct |
20 |
Correct |
6 ms |
1676 KB |
Output is correct |
21 |
Correct |
8 ms |
1748 KB |
Output is correct |
22 |
Correct |
6 ms |
1640 KB |
Output is correct |
23 |
Correct |
4 ms |
1748 KB |
Output is correct |
24 |
Correct |
7 ms |
1748 KB |
Output is correct |
25 |
Correct |
5 ms |
1748 KB |
Output is correct |
26 |
Correct |
4 ms |
1748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 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 |
0 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 |
340 KB |
Output is correct |
14 |
Correct |
6 ms |
1536 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
4 ms |
1104 KB |
Output is correct |
17 |
Correct |
1 ms |
324 KB |
Output is correct |
18 |
Correct |
9 ms |
1876 KB |
Output is correct |
19 |
Correct |
5 ms |
1736 KB |
Output is correct |
20 |
Correct |
6 ms |
1676 KB |
Output is correct |
21 |
Correct |
8 ms |
1748 KB |
Output is correct |
22 |
Correct |
6 ms |
1640 KB |
Output is correct |
23 |
Correct |
4 ms |
1748 KB |
Output is correct |
24 |
Correct |
7 ms |
1748 KB |
Output is correct |
25 |
Correct |
5 ms |
1748 KB |
Output is correct |
26 |
Correct |
4 ms |
1748 KB |
Output is correct |
27 |
Correct |
289 ms |
50420 KB |
Output is correct |
28 |
Correct |
1 ms |
596 KB |
Output is correct |
29 |
Correct |
14 ms |
4044 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
224 ms |
37076 KB |
Output is correct |
32 |
Correct |
209 ms |
53004 KB |
Output is correct |
33 |
Correct |
231 ms |
53136 KB |
Output is correct |
34 |
Correct |
280 ms |
43012 KB |
Output is correct |
35 |
Correct |
217 ms |
52904 KB |
Output is correct |
36 |
Correct |
221 ms |
53172 KB |
Output is correct |
37 |
Correct |
370 ms |
53244 KB |
Output is correct |
38 |
Correct |
132 ms |
36900 KB |
Output is correct |
39 |
Correct |
149 ms |
37036 KB |
Output is correct |