//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int N = 3005;
char a[N][N];
int row[N][N];
int col[N][N];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, m;
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 = m; j >= 1; j--) {
row[i][j] = row[i][j + 1] + (a[i][j] == 'O');
}
}
for (int j = 1; j <= m; j++) {
for (int i = n; i >= 1; i--) {
col[i][j] = col[i + 1][j] + (a[i][j] == 'I');
}
}
ll ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] == 'J') {
ans += ll(row[i][j + 1]) * col[i + 1][j];
}
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1656 KB |
Output is correct |
6 |
Correct |
3 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1528 KB |
Output is correct |
13 |
Correct |
4 ms |
1400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1656 KB |
Output is correct |
6 |
Correct |
3 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1528 KB |
Output is correct |
13 |
Correct |
4 ms |
1400 KB |
Output is correct |
14 |
Correct |
13 ms |
7592 KB |
Output is correct |
15 |
Correct |
6 ms |
4984 KB |
Output is correct |
16 |
Correct |
9 ms |
4128 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
18 ms |
8056 KB |
Output is correct |
19 |
Correct |
16 ms |
7984 KB |
Output is correct |
20 |
Correct |
17 ms |
7928 KB |
Output is correct |
21 |
Correct |
18 ms |
8004 KB |
Output is correct |
22 |
Correct |
16 ms |
7928 KB |
Output is correct |
23 |
Correct |
29 ms |
7928 KB |
Output is correct |
24 |
Correct |
17 ms |
8056 KB |
Output is correct |
25 |
Correct |
16 ms |
7928 KB |
Output is correct |
26 |
Correct |
14 ms |
7804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1656 KB |
Output is correct |
6 |
Correct |
3 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1528 KB |
Output is correct |
13 |
Correct |
4 ms |
1400 KB |
Output is correct |
14 |
Correct |
13 ms |
7592 KB |
Output is correct |
15 |
Correct |
6 ms |
4984 KB |
Output is correct |
16 |
Correct |
9 ms |
4128 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
18 ms |
8056 KB |
Output is correct |
19 |
Correct |
16 ms |
7984 KB |
Output is correct |
20 |
Correct |
17 ms |
7928 KB |
Output is correct |
21 |
Correct |
18 ms |
8004 KB |
Output is correct |
22 |
Correct |
16 ms |
7928 KB |
Output is correct |
23 |
Correct |
29 ms |
7928 KB |
Output is correct |
24 |
Correct |
17 ms |
8056 KB |
Output is correct |
25 |
Correct |
16 ms |
7928 KB |
Output is correct |
26 |
Correct |
14 ms |
7804 KB |
Output is correct |
27 |
Correct |
461 ms |
88024 KB |
Output is correct |
28 |
Correct |
27 ms |
26104 KB |
Output is correct |
29 |
Correct |
25 ms |
7800 KB |
Output is correct |
30 |
Correct |
3 ms |
632 KB |
Output is correct |
31 |
Correct |
340 ms |
72700 KB |
Output is correct |
32 |
Correct |
452 ms |
88568 KB |
Output is correct |
33 |
Correct |
453 ms |
88472 KB |
Output is correct |
34 |
Correct |
400 ms |
84444 KB |
Output is correct |
35 |
Correct |
460 ms |
88608 KB |
Output is correct |
36 |
Correct |
444 ms |
88312 KB |
Output is correct |
37 |
Correct |
485 ms |
88652 KB |
Output is correct |
38 |
Correct |
313 ms |
72568 KB |
Output is correct |
39 |
Correct |
309 ms |
72532 KB |
Output is correct |