#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int n, m, row[N][N], col[N][N];
char a[N][N];
long long ans = 0;
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j];
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) row[i][j] = row[i][j - 1] + (a[i][j] == 'O');
for (int i = 1; i <= m; i++) for (int j = 1; j <= n; j++) col[i][j] = col[i][j - 1] + (a[j][i] == 'I');
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] == 'J') ans += 1LL * (row[i][m] - row[i][j]) * (col[j][n] - col[j][i]);
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1408 KB |
Output is correct |
7 |
Correct |
3 ms |
1408 KB |
Output is correct |
8 |
Correct |
3 ms |
1536 KB |
Output is correct |
9 |
Correct |
3 ms |
1408 KB |
Output is correct |
10 |
Correct |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
3 ms |
1408 KB |
Output is correct |
13 |
Correct |
4 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1408 KB |
Output is correct |
7 |
Correct |
3 ms |
1408 KB |
Output is correct |
8 |
Correct |
3 ms |
1536 KB |
Output is correct |
9 |
Correct |
3 ms |
1408 KB |
Output is correct |
10 |
Correct |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
3 ms |
1408 KB |
Output is correct |
13 |
Correct |
4 ms |
1408 KB |
Output is correct |
14 |
Correct |
12 ms |
6784 KB |
Output is correct |
15 |
Correct |
5 ms |
3328 KB |
Output is correct |
16 |
Correct |
10 ms |
5120 KB |
Output is correct |
17 |
Correct |
4 ms |
1664 KB |
Output is correct |
18 |
Correct |
15 ms |
7808 KB |
Output is correct |
19 |
Correct |
14 ms |
7552 KB |
Output is correct |
20 |
Correct |
15 ms |
7808 KB |
Output is correct |
21 |
Correct |
15 ms |
7808 KB |
Output is correct |
22 |
Correct |
14 ms |
7680 KB |
Output is correct |
23 |
Correct |
14 ms |
7680 KB |
Output is correct |
24 |
Correct |
14 ms |
7936 KB |
Output is correct |
25 |
Correct |
14 ms |
7680 KB |
Output is correct |
26 |
Correct |
15 ms |
7680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1408 KB |
Output is correct |
7 |
Correct |
3 ms |
1408 KB |
Output is correct |
8 |
Correct |
3 ms |
1536 KB |
Output is correct |
9 |
Correct |
3 ms |
1408 KB |
Output is correct |
10 |
Correct |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
3 ms |
1408 KB |
Output is correct |
13 |
Correct |
4 ms |
1408 KB |
Output is correct |
14 |
Correct |
12 ms |
6784 KB |
Output is correct |
15 |
Correct |
5 ms |
3328 KB |
Output is correct |
16 |
Correct |
10 ms |
5120 KB |
Output is correct |
17 |
Correct |
4 ms |
1664 KB |
Output is correct |
18 |
Correct |
15 ms |
7808 KB |
Output is correct |
19 |
Correct |
14 ms |
7552 KB |
Output is correct |
20 |
Correct |
15 ms |
7808 KB |
Output is correct |
21 |
Correct |
15 ms |
7808 KB |
Output is correct |
22 |
Correct |
14 ms |
7680 KB |
Output is correct |
23 |
Correct |
14 ms |
7680 KB |
Output is correct |
24 |
Correct |
14 ms |
7936 KB |
Output is correct |
25 |
Correct |
14 ms |
7680 KB |
Output is correct |
26 |
Correct |
15 ms |
7680 KB |
Output is correct |
27 |
Correct |
325 ms |
77716 KB |
Output is correct |
28 |
Correct |
21 ms |
16768 KB |
Output is correct |
29 |
Correct |
34 ms |
16760 KB |
Output is correct |
30 |
Correct |
14 ms |
9856 KB |
Output is correct |
31 |
Correct |
231 ms |
66524 KB |
Output is correct |
32 |
Correct |
275 ms |
79540 KB |
Output is correct |
33 |
Correct |
257 ms |
79612 KB |
Output is correct |
34 |
Correct |
255 ms |
72312 KB |
Output is correct |
35 |
Correct |
277 ms |
79480 KB |
Output is correct |
36 |
Correct |
279 ms |
79552 KB |
Output is correct |
37 |
Correct |
346 ms |
79884 KB |
Output is correct |
38 |
Correct |
190 ms |
66488 KB |
Output is correct |
39 |
Correct |
187 ms |
66324 KB |
Output is correct |