#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define int long long
struct item {
int o, i;
};
int32_t main() {
ios::sync_with_stdio(0); cin.tie(0);
int n, m; cin >> n >> m;
vector<vector<char>> a(n + 1, vector<char>(m + 1));
vector<vector<item>> cnt(n + 1, vector<item>(m + 1));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
if (a[i][j] == 'O') cnt[i][j].o++;
if (a[i][j] == 'I') cnt[i][j].i++;
cnt[i][j].o += cnt[i][j - 1].o;
cnt[i][j].i += cnt[i - 1][j].i;
}
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] == 'J') {
ans += (cnt[i][m].o - cnt[i][j].o) * (cnt[n][j].i - cnt[i][j].i);
}
}
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
14 |
Correct |
8 ms |
3532 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
6 ms |
2380 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
11 ms |
4428 KB |
Output is correct |
19 |
Correct |
8 ms |
4364 KB |
Output is correct |
20 |
Correct |
8 ms |
4448 KB |
Output is correct |
21 |
Correct |
11 ms |
4768 KB |
Output is correct |
22 |
Correct |
9 ms |
4556 KB |
Output is correct |
23 |
Correct |
8 ms |
4684 KB |
Output is correct |
24 |
Correct |
11 ms |
4780 KB |
Output is correct |
25 |
Correct |
9 ms |
4556 KB |
Output is correct |
26 |
Correct |
8 ms |
4684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
14 |
Correct |
8 ms |
3532 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
6 ms |
2380 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
11 ms |
4428 KB |
Output is correct |
19 |
Correct |
8 ms |
4364 KB |
Output is correct |
20 |
Correct |
8 ms |
4448 KB |
Output is correct |
21 |
Correct |
11 ms |
4768 KB |
Output is correct |
22 |
Correct |
9 ms |
4556 KB |
Output is correct |
23 |
Correct |
8 ms |
4684 KB |
Output is correct |
24 |
Correct |
11 ms |
4780 KB |
Output is correct |
25 |
Correct |
9 ms |
4556 KB |
Output is correct |
26 |
Correct |
8 ms |
4684 KB |
Output is correct |
27 |
Correct |
340 ms |
150380 KB |
Output is correct |
28 |
Correct |
2 ms |
972 KB |
Output is correct |
29 |
Correct |
20 ms |
11812 KB |
Output is correct |
30 |
Correct |
1 ms |
716 KB |
Output is correct |
31 |
Correct |
250 ms |
110596 KB |
Output is correct |
32 |
Correct |
287 ms |
158036 KB |
Output is correct |
33 |
Correct |
245 ms |
158608 KB |
Output is correct |
34 |
Correct |
293 ms |
128372 KB |
Output is correct |
35 |
Correct |
294 ms |
158064 KB |
Output is correct |
36 |
Correct |
267 ms |
158604 KB |
Output is correct |
37 |
Correct |
361 ms |
159156 KB |
Output is correct |
38 |
Correct |
195 ms |
109752 KB |
Output is correct |
39 |
Correct |
169 ms |
110236 KB |
Output is correct |