#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 3030;
char c[N][N];
int qs[2][N][N];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int i = 1;i <= n;i++) {
cin >> (c[i] + 1);
for (int j = 1;j <= m;j++) {
qs[0][i][j] = qs[0][i][j - 1] + (c[i][j] == 'O');
qs[1][i][j] = qs[1][i - 1][j] + (c[i][j] == 'I');
}
}
ll ans = 0;
for (int i = 1;i < n;i++) {
for (int j = 1;j < m;j++) {
if (c[i][j] == 'J') {
ans += 1ll * (qs[0][i][m] - qs[0][i][j]) * (qs[1][n][j] - qs[1][i][j]);
}
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
7516 KB |
Output is correct |
6 |
Correct |
1 ms |
7372 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
2 ms |
7260 KB |
Output is correct |
9 |
Correct |
2 ms |
7260 KB |
Output is correct |
10 |
Correct |
1 ms |
5212 KB |
Output is correct |
11 |
Correct |
2 ms |
7388 KB |
Output is correct |
12 |
Correct |
2 ms |
7260 KB |
Output is correct |
13 |
Correct |
2 ms |
5212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
7516 KB |
Output is correct |
6 |
Correct |
1 ms |
7372 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
2 ms |
7260 KB |
Output is correct |
9 |
Correct |
2 ms |
7260 KB |
Output is correct |
10 |
Correct |
1 ms |
5212 KB |
Output is correct |
11 |
Correct |
2 ms |
7388 KB |
Output is correct |
12 |
Correct |
2 ms |
7260 KB |
Output is correct |
13 |
Correct |
2 ms |
5212 KB |
Output is correct |
14 |
Correct |
4 ms |
14172 KB |
Output is correct |
15 |
Correct |
2 ms |
10588 KB |
Output is correct |
16 |
Correct |
3 ms |
8796 KB |
Output is correct |
17 |
Correct |
1 ms |
2512 KB |
Output is correct |
18 |
Correct |
5 ms |
14428 KB |
Output is correct |
19 |
Correct |
4 ms |
14684 KB |
Output is correct |
20 |
Correct |
4 ms |
14428 KB |
Output is correct |
21 |
Correct |
5 ms |
14464 KB |
Output is correct |
22 |
Correct |
4 ms |
14428 KB |
Output is correct |
23 |
Correct |
5 ms |
14680 KB |
Output is correct |
24 |
Correct |
6 ms |
14428 KB |
Output is correct |
25 |
Correct |
5 ms |
14300 KB |
Output is correct |
26 |
Correct |
4 ms |
14300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
7516 KB |
Output is correct |
6 |
Correct |
1 ms |
7372 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
2 ms |
7260 KB |
Output is correct |
9 |
Correct |
2 ms |
7260 KB |
Output is correct |
10 |
Correct |
1 ms |
5212 KB |
Output is correct |
11 |
Correct |
2 ms |
7388 KB |
Output is correct |
12 |
Correct |
2 ms |
7260 KB |
Output is correct |
13 |
Correct |
2 ms |
5212 KB |
Output is correct |
14 |
Correct |
4 ms |
14172 KB |
Output is correct |
15 |
Correct |
2 ms |
10588 KB |
Output is correct |
16 |
Correct |
3 ms |
8796 KB |
Output is correct |
17 |
Correct |
1 ms |
2512 KB |
Output is correct |
18 |
Correct |
5 ms |
14428 KB |
Output is correct |
19 |
Correct |
4 ms |
14684 KB |
Output is correct |
20 |
Correct |
4 ms |
14428 KB |
Output is correct |
21 |
Correct |
5 ms |
14464 KB |
Output is correct |
22 |
Correct |
4 ms |
14428 KB |
Output is correct |
23 |
Correct |
5 ms |
14680 KB |
Output is correct |
24 |
Correct |
6 ms |
14428 KB |
Output is correct |
25 |
Correct |
5 ms |
14300 KB |
Output is correct |
26 |
Correct |
4 ms |
14300 KB |
Output is correct |
27 |
Correct |
97 ms |
88912 KB |
Output is correct |
28 |
Correct |
10 ms |
47196 KB |
Output is correct |
29 |
Correct |
6 ms |
12632 KB |
Output is correct |
30 |
Correct |
1 ms |
2652 KB |
Output is correct |
31 |
Correct |
56 ms |
76380 KB |
Output is correct |
32 |
Correct |
51 ms |
89596 KB |
Output is correct |
33 |
Correct |
51 ms |
89424 KB |
Output is correct |
34 |
Correct |
66 ms |
86460 KB |
Output is correct |
35 |
Correct |
57 ms |
89420 KB |
Output is correct |
36 |
Correct |
52 ms |
89356 KB |
Output is correct |
37 |
Correct |
83 ms |
89656 KB |
Output is correct |
38 |
Correct |
39 ms |
76116 KB |
Output is correct |
39 |
Correct |
38 ms |
76236 KB |
Output is correct |