#include <bits/stdc++.h>
using namespace std;
#define num long long
const int W = 3000;
const int H = W;
num dp0[W][H];
num dp1[W][H];
bool dp2[W][H];
int main () {
int w, h;
cin >> w >> h;
for (int i = 0; i < w; i ++) {
string b;
cin >> b;
for (int j = 0; j < h; j ++) {
if (b[j] == 'J') dp2[i][j] = true;
if (b[j] == 'O') dp1[i][j] = 1;
if (b[j] == 'I') dp0[i][j] = 1;
}
}
for (int i = w - 2; i >= 0; i --)
for (int j = 0; j < h; j ++)
dp0[i][j] += dp0[i + 1][j];
for (int j = h - 2; j >= 0; j --)
for (int i = 0; i < w; i ++)
dp1[i][j] += dp1[i][j + 1];
num ans = 0;
for (int i = 0; i < w; i ++)
for (int j = 0; j < h; j ++)
if (dp2[i][j])
ans += dp0[i][j] * dp1[i][j];
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1464 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1340 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1464 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1340 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1340 KB |
Output is correct |
14 |
Correct |
11 ms |
8900 KB |
Output is correct |
15 |
Correct |
3 ms |
4920 KB |
Output is correct |
16 |
Correct |
6 ms |
5184 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
13 ms |
9860 KB |
Output is correct |
19 |
Correct |
10 ms |
9728 KB |
Output is correct |
20 |
Correct |
11 ms |
9684 KB |
Output is correct |
21 |
Correct |
12 ms |
9832 KB |
Output is correct |
22 |
Correct |
11 ms |
9736 KB |
Output is correct |
23 |
Correct |
10 ms |
9664 KB |
Output is correct |
24 |
Correct |
12 ms |
9940 KB |
Output is correct |
25 |
Correct |
10 ms |
9736 KB |
Output is correct |
26 |
Correct |
10 ms |
9708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1464 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1340 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1340 KB |
Output is correct |
14 |
Correct |
11 ms |
8900 KB |
Output is correct |
15 |
Correct |
3 ms |
4920 KB |
Output is correct |
16 |
Correct |
6 ms |
5184 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
13 ms |
9860 KB |
Output is correct |
19 |
Correct |
10 ms |
9728 KB |
Output is correct |
20 |
Correct |
11 ms |
9684 KB |
Output is correct |
21 |
Correct |
12 ms |
9832 KB |
Output is correct |
22 |
Correct |
11 ms |
9736 KB |
Output is correct |
23 |
Correct |
10 ms |
9664 KB |
Output is correct |
24 |
Correct |
12 ms |
9940 KB |
Output is correct |
25 |
Correct |
10 ms |
9736 KB |
Output is correct |
26 |
Correct |
10 ms |
9708 KB |
Output is correct |
27 |
Correct |
403 ms |
153424 KB |
Output is correct |
28 |
Correct |
12 ms |
25724 KB |
Output is correct |
29 |
Correct |
22 ms |
13780 KB |
Output is correct |
30 |
Correct |
1 ms |
708 KB |
Output is correct |
31 |
Correct |
310 ms |
128436 KB |
Output is correct |
32 |
Correct |
358 ms |
153416 KB |
Output is correct |
33 |
Correct |
337 ms |
153048 KB |
Output is correct |
34 |
Correct |
345 ms |
148428 KB |
Output is correct |
35 |
Correct |
358 ms |
153436 KB |
Output is correct |
36 |
Correct |
337 ms |
152960 KB |
Output is correct |
37 |
Correct |
422 ms |
153420 KB |
Output is correct |
38 |
Correct |
251 ms |
127720 KB |
Output is correct |
39 |
Correct |
240 ms |
127972 KB |
Output is correct |