#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 3005;
char a[N][N];
int cntO[N][N], cntI[N][N];
signed main() {
// freopen("in" , "r", stdin );
cin.tie(0)->sync_with_stdio(0);
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
if (a[i][j] == 'O') cntO[i][j]++;
if (a[i][j] == 'I') cntI[i][j]++;
cntO[i][j] += cntO[i][j - 1];
cntI[i][j] += cntI[i - 1][j];
}
int ans = 0;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) {
if (a[i][j] == 'J') {
ans += (cntO[i][m] - cntO[i][j]) * (cntI[n][j] - cntI[i][j]);
}
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
1484 KB |
Output is correct |
6 |
Correct |
1 ms |
1476 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
2 ms |
1612 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
1 ms |
1484 KB |
Output is correct |
11 |
Correct |
2 ms |
1604 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
1484 KB |
Output is correct |
6 |
Correct |
1 ms |
1476 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
2 ms |
1612 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
1 ms |
1484 KB |
Output is correct |
11 |
Correct |
2 ms |
1604 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
12 ms |
8952 KB |
Output is correct |
15 |
Correct |
3 ms |
4940 KB |
Output is correct |
16 |
Correct |
6 ms |
5324 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
14 ms |
9908 KB |
Output is correct |
19 |
Correct |
12 ms |
9728 KB |
Output is correct |
20 |
Correct |
11 ms |
9780 KB |
Output is correct |
21 |
Correct |
14 ms |
9932 KB |
Output is correct |
22 |
Correct |
12 ms |
9804 KB |
Output is correct |
23 |
Correct |
11 ms |
9676 KB |
Output is correct |
24 |
Correct |
14 ms |
9932 KB |
Output is correct |
25 |
Correct |
11 ms |
9752 KB |
Output is correct |
26 |
Correct |
11 ms |
9676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
1484 KB |
Output is correct |
6 |
Correct |
1 ms |
1476 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
2 ms |
1612 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
1 ms |
1484 KB |
Output is correct |
11 |
Correct |
2 ms |
1604 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
12 ms |
8952 KB |
Output is correct |
15 |
Correct |
3 ms |
4940 KB |
Output is correct |
16 |
Correct |
6 ms |
5324 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
14 ms |
9908 KB |
Output is correct |
19 |
Correct |
12 ms |
9728 KB |
Output is correct |
20 |
Correct |
11 ms |
9780 KB |
Output is correct |
21 |
Correct |
14 ms |
9932 KB |
Output is correct |
22 |
Correct |
12 ms |
9804 KB |
Output is correct |
23 |
Correct |
11 ms |
9676 KB |
Output is correct |
24 |
Correct |
14 ms |
9932 KB |
Output is correct |
25 |
Correct |
11 ms |
9752 KB |
Output is correct |
26 |
Correct |
11 ms |
9676 KB |
Output is correct |
27 |
Correct |
359 ms |
158556 KB |
Output is correct |
28 |
Correct |
17 ms |
26316 KB |
Output is correct |
29 |
Correct |
21 ms |
13872 KB |
Output is correct |
30 |
Correct |
2 ms |
716 KB |
Output is correct |
31 |
Correct |
270 ms |
131284 KB |
Output is correct |
32 |
Correct |
291 ms |
158884 KB |
Output is correct |
33 |
Correct |
248 ms |
158420 KB |
Output is correct |
34 |
Correct |
314 ms |
152352 KB |
Output is correct |
35 |
Correct |
301 ms |
159004 KB |
Output is correct |
36 |
Correct |
246 ms |
158532 KB |
Output is correct |
37 |
Correct |
373 ms |
159232 KB |
Output is correct |
38 |
Correct |
210 ms |
130888 KB |
Output is correct |
39 |
Correct |
185 ms |
130792 KB |
Output is correct |