#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long llong;
int h, w;
char grid[3000][3001];
int Ocnt[3001][3001];
int Icnt[3001][3001];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> h >> w;
for (int i = 0; i < h; ++i) {
cin >> grid[i];
}
for (int i = h; i--; ) {
for (int j = w; j--; ) {
Ocnt[i][j] = Ocnt[i][j + 1];
Icnt[i][j] = Icnt[i + 1][j];
if (grid[i][j] == 'O') ++Ocnt[i][j];
if (grid[i][j] == 'I') ++Icnt[i][j];
}
}
llong ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (grid[i][j] == 'J') ans += Ocnt[i][j] * Icnt[i][j];
}
}
printf("%lld\n", ans);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 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 |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
3 ms |
1536 KB |
Output is correct |
12 |
Correct |
3 ms |
1536 KB |
Output is correct |
13 |
Correct |
4 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 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 |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
3 ms |
1536 KB |
Output is correct |
12 |
Correct |
3 ms |
1536 KB |
Output is correct |
13 |
Correct |
4 ms |
1408 KB |
Output is correct |
14 |
Correct |
11 ms |
7552 KB |
Output is correct |
15 |
Correct |
7 ms |
4992 KB |
Output is correct |
16 |
Correct |
6 ms |
4352 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
12 ms |
7936 KB |
Output is correct |
19 |
Correct |
10 ms |
7936 KB |
Output is correct |
20 |
Correct |
11 ms |
7808 KB |
Output is correct |
21 |
Correct |
13 ms |
8064 KB |
Output is correct |
22 |
Correct |
11 ms |
7892 KB |
Output is correct |
23 |
Correct |
11 ms |
7808 KB |
Output is correct |
24 |
Correct |
12 ms |
7936 KB |
Output is correct |
25 |
Correct |
11 ms |
7848 KB |
Output is correct |
26 |
Correct |
10 ms |
7780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 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 |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
3 ms |
1536 KB |
Output is correct |
12 |
Correct |
3 ms |
1536 KB |
Output is correct |
13 |
Correct |
4 ms |
1408 KB |
Output is correct |
14 |
Correct |
11 ms |
7552 KB |
Output is correct |
15 |
Correct |
7 ms |
4992 KB |
Output is correct |
16 |
Correct |
6 ms |
4352 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
12 ms |
7936 KB |
Output is correct |
19 |
Correct |
10 ms |
7936 KB |
Output is correct |
20 |
Correct |
11 ms |
7808 KB |
Output is correct |
21 |
Correct |
13 ms |
8064 KB |
Output is correct |
22 |
Correct |
11 ms |
7892 KB |
Output is correct |
23 |
Correct |
11 ms |
7808 KB |
Output is correct |
24 |
Correct |
12 ms |
7936 KB |
Output is correct |
25 |
Correct |
11 ms |
7848 KB |
Output is correct |
26 |
Correct |
10 ms |
7780 KB |
Output is correct |
27 |
Correct |
180 ms |
84368 KB |
Output is correct |
28 |
Correct |
26 ms |
26084 KB |
Output is correct |
29 |
Correct |
10 ms |
7808 KB |
Output is correct |
30 |
Correct |
3 ms |
640 KB |
Output is correct |
31 |
Correct |
141 ms |
70904 KB |
Output is correct |
32 |
Correct |
119 ms |
85368 KB |
Output is correct |
33 |
Correct |
121 ms |
85228 KB |
Output is correct |
34 |
Correct |
172 ms |
81460 KB |
Output is correct |
35 |
Correct |
133 ms |
85456 KB |
Output is correct |
36 |
Correct |
126 ms |
85068 KB |
Output is correct |
37 |
Correct |
181 ms |
85416 KB |
Output is correct |
38 |
Correct |
87 ms |
70776 KB |
Output is correct |
39 |
Correct |
94 ms |
70540 KB |
Output is correct |