#include "bits/stdc++.h"
using namespace std;
#define int long long
signed main() {
ios::sync_with_stdio(0); cin.tie();
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 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 |
512 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 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 |
512 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 |
4 ms |
3712 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
3 ms |
2688 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
4864 KB |
Output is correct |
19 |
Correct |
5 ms |
4640 KB |
Output is correct |
20 |
Correct |
7 ms |
4736 KB |
Output is correct |
21 |
Correct |
5 ms |
4864 KB |
Output is correct |
22 |
Correct |
7 ms |
4608 KB |
Output is correct |
23 |
Correct |
5 ms |
4736 KB |
Output is correct |
24 |
Correct |
6 ms |
4736 KB |
Output is correct |
25 |
Correct |
6 ms |
4608 KB |
Output is correct |
26 |
Correct |
5 ms |
4736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 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 |
512 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 |
4 ms |
3712 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
3 ms |
2688 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
4864 KB |
Output is correct |
19 |
Correct |
5 ms |
4640 KB |
Output is correct |
20 |
Correct |
7 ms |
4736 KB |
Output is correct |
21 |
Correct |
5 ms |
4864 KB |
Output is correct |
22 |
Correct |
7 ms |
4608 KB |
Output is correct |
23 |
Correct |
5 ms |
4736 KB |
Output is correct |
24 |
Correct |
6 ms |
4736 KB |
Output is correct |
25 |
Correct |
6 ms |
4608 KB |
Output is correct |
26 |
Correct |
5 ms |
4736 KB |
Output is correct |
27 |
Correct |
168 ms |
143192 KB |
Output is correct |
28 |
Correct |
2 ms |
1024 KB |
Output is correct |
29 |
Correct |
16 ms |
11648 KB |
Output is correct |
30 |
Correct |
1 ms |
768 KB |
Output is correct |
31 |
Correct |
123 ms |
105472 KB |
Output is correct |
32 |
Correct |
167 ms |
150776 KB |
Output is correct |
33 |
Correct |
180 ms |
151160 KB |
Output is correct |
34 |
Correct |
150 ms |
122232 KB |
Output is correct |
35 |
Correct |
168 ms |
150520 KB |
Output is correct |
36 |
Correct |
165 ms |
151032 KB |
Output is correct |
37 |
Correct |
169 ms |
151624 KB |
Output is correct |
38 |
Correct |
121 ms |
104568 KB |
Output is correct |
39 |
Correct |
129 ms |
104952 KB |
Output is correct |