#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) x.begin(), x.end()
int col[3002][3002], row[3002][3002];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<string> v(n);
for (int i = 0; i < n; i++) cin >> v[i];
for (int i = 0; i < n; i++) {
for (int j = m - 1; j >= 0; j--) {
row[i][j] = row[i][j + 1];
row[i][j] += (v[i][j] == 'O');
}
}
for (int j = 0; j < m; j++) {
for (int i = n - 1; i >= 0; i--) {
col[i][j] += col[i + 1][j];
col[i][j] += (v[i][j] == 'I');
}
}
ll ans = 0;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < m - 1; j++) {
if (v[i][j] == 'J') ans += row[i][j + 1] * col[i + 1][j];
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1108 KB |
Output is correct |
6 |
Correct |
1 ms |
1108 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
1 ms |
1236 KB |
Output is correct |
9 |
Correct |
1 ms |
1108 KB |
Output is correct |
10 |
Correct |
1 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
1 ms |
1108 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1108 KB |
Output is correct |
6 |
Correct |
1 ms |
1108 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
1 ms |
1236 KB |
Output is correct |
9 |
Correct |
1 ms |
1108 KB |
Output is correct |
10 |
Correct |
1 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
1 ms |
1108 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
14 |
Correct |
5 ms |
6228 KB |
Output is correct |
15 |
Correct |
2 ms |
3668 KB |
Output is correct |
16 |
Correct |
2 ms |
3668 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
6740 KB |
Output is correct |
19 |
Correct |
4 ms |
6612 KB |
Output is correct |
20 |
Correct |
5 ms |
6612 KB |
Output is correct |
21 |
Correct |
6 ms |
6720 KB |
Output is correct |
22 |
Correct |
5 ms |
6628 KB |
Output is correct |
23 |
Correct |
5 ms |
6612 KB |
Output is correct |
24 |
Correct |
6 ms |
6864 KB |
Output is correct |
25 |
Correct |
5 ms |
6612 KB |
Output is correct |
26 |
Correct |
4 ms |
6612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1108 KB |
Output is correct |
6 |
Correct |
1 ms |
1108 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
1 ms |
1236 KB |
Output is correct |
9 |
Correct |
1 ms |
1108 KB |
Output is correct |
10 |
Correct |
1 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
1 ms |
1108 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
14 |
Correct |
5 ms |
6228 KB |
Output is correct |
15 |
Correct |
2 ms |
3668 KB |
Output is correct |
16 |
Correct |
2 ms |
3668 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
6740 KB |
Output is correct |
19 |
Correct |
4 ms |
6612 KB |
Output is correct |
20 |
Correct |
5 ms |
6612 KB |
Output is correct |
21 |
Correct |
6 ms |
6720 KB |
Output is correct |
22 |
Correct |
5 ms |
6628 KB |
Output is correct |
23 |
Correct |
5 ms |
6612 KB |
Output is correct |
24 |
Correct |
6 ms |
6864 KB |
Output is correct |
25 |
Correct |
5 ms |
6612 KB |
Output is correct |
26 |
Correct |
4 ms |
6612 KB |
Output is correct |
27 |
Correct |
206 ms |
88220 KB |
Output is correct |
28 |
Correct |
11 ms |
19252 KB |
Output is correct |
29 |
Correct |
7 ms |
7732 KB |
Output is correct |
30 |
Correct |
1 ms |
596 KB |
Output is correct |
31 |
Correct |
153 ms |
71836 KB |
Output is correct |
32 |
Correct |
203 ms |
89268 KB |
Output is correct |
33 |
Correct |
202 ms |
89040 KB |
Output is correct |
34 |
Correct |
186 ms |
83344 KB |
Output is correct |
35 |
Correct |
197 ms |
89292 KB |
Output is correct |
36 |
Correct |
196 ms |
89036 KB |
Output is correct |
37 |
Correct |
221 ms |
89392 KB |
Output is correct |
38 |
Correct |
132 ms |
71716 KB |
Output is correct |
39 |
Correct |
128 ms |
71492 KB |
Output is correct |