#include "bits/stdc++.h"
using namespace std;
#define int long long
signed main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
for (int i = 0; i < h; ++i)
cin >> s[i];
vector<vector<int>> cnt_o(h, vector<int>(w, 0));
vector<vector<int>> cnt_i(h, vector<int>(w, 0));
for (int i = h - 1; i >= 0; --i) {
for (int j = 0; j < w; ++j) {
cnt_i[i][j] = ((i + 1 < h) ? cnt_i[i + 1][j] : 0) + (s[i][j] == 'I');
}
}
for (int i = 0; i < h; ++i) {
for (int j = w - 1; j >= 0; --j) {
cnt_o[i][j] = ((j + 1 < w) ? cnt_o[i][j + 1] : 0) + (s[i][j] == 'O');
}
}
int ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
ans += (s[i][j] == 'J') * cnt_i[i][j] * cnt_o[i][j];
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
544 KB |
Output is correct |
8 |
Correct |
1 ms |
512 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
13 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
544 KB |
Output is correct |
8 |
Correct |
1 ms |
512 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
13 |
Correct |
1 ms |
512 KB |
Output is correct |
14 |
Correct |
14 ms |
3840 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
9 ms |
2688 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
17 ms |
4992 KB |
Output is correct |
19 |
Correct |
16 ms |
4736 KB |
Output is correct |
20 |
Correct |
16 ms |
4864 KB |
Output is correct |
21 |
Correct |
17 ms |
4992 KB |
Output is correct |
22 |
Correct |
18 ms |
4608 KB |
Output is correct |
23 |
Correct |
16 ms |
4864 KB |
Output is correct |
24 |
Correct |
17 ms |
4992 KB |
Output is correct |
25 |
Correct |
16 ms |
4640 KB |
Output is correct |
26 |
Correct |
17 ms |
4864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
544 KB |
Output is correct |
8 |
Correct |
1 ms |
512 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
13 |
Correct |
1 ms |
512 KB |
Output is correct |
14 |
Correct |
14 ms |
3840 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
9 ms |
2688 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
17 ms |
4992 KB |
Output is correct |
19 |
Correct |
16 ms |
4736 KB |
Output is correct |
20 |
Correct |
16 ms |
4864 KB |
Output is correct |
21 |
Correct |
17 ms |
4992 KB |
Output is correct |
22 |
Correct |
18 ms |
4608 KB |
Output is correct |
23 |
Correct |
16 ms |
4864 KB |
Output is correct |
24 |
Correct |
17 ms |
4992 KB |
Output is correct |
25 |
Correct |
16 ms |
4640 KB |
Output is correct |
26 |
Correct |
17 ms |
4864 KB |
Output is correct |
27 |
Correct |
555 ms |
153332 KB |
Output is correct |
28 |
Correct |
3 ms |
896 KB |
Output is correct |
29 |
Correct |
43 ms |
12160 KB |
Output is correct |
30 |
Correct |
2 ms |
768 KB |
Output is correct |
31 |
Correct |
406 ms |
114040 KB |
Output is correct |
32 |
Correct |
581 ms |
160760 KB |
Output is correct |
33 |
Correct |
586 ms |
161140 KB |
Output is correct |
34 |
Correct |
459 ms |
132144 KB |
Output is correct |
35 |
Correct |
576 ms |
160888 KB |
Output is correct |
36 |
Correct |
580 ms |
161212 KB |
Output is correct |
37 |
Correct |
583 ms |
161840 KB |
Output is correct |
38 |
Correct |
419 ms |
113272 KB |
Output is correct |
39 |
Correct |
484 ms |
113528 KB |
Output is correct |