#include <iostream>
using namespace std;
#define MAXN 3005
int h, w;
char grid[MAXN][MAXN];
int row[MAXN][MAXN];
int col[MAXN][MAXN];
long long o = 0;
int main () {
cin >> h >> w;
for (int i=1; i<=h; i++) {
for (int j=1; j<=w; j++) {
cin >> grid[i][j];
}
}
for (int i=1; i<=h; i++) {
for (int j=1; j<=w; j++) {
row[i][j] = row[i][j-1];
if (grid[i][j] == 'O') row[i][j]++;
col[i][j] = col[i-1][j];
if (grid[i][j] == 'I') col[i][j]++;
}
}
for (int i=1; i<=h; i++) {
for (int j=1; j<=w; j++) {
if (grid[i][j] == 'J') o += (row[i][w]-row[i][j])*(col[h][j]-col[i][j]);
}
}
cout << o << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1536 KB |
Output is correct |
6 |
Correct |
2 ms |
1536 KB |
Output is correct |
7 |
Correct |
2 ms |
1408 KB |
Output is correct |
8 |
Correct |
2 ms |
1536 KB |
Output is correct |
9 |
Correct |
2 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 ms |
1408 KB |
Output is correct |
11 |
Correct |
2 ms |
1536 KB |
Output is correct |
12 |
Correct |
2 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1536 KB |
Output is correct |
6 |
Correct |
2 ms |
1536 KB |
Output is correct |
7 |
Correct |
2 ms |
1408 KB |
Output is correct |
8 |
Correct |
2 ms |
1536 KB |
Output is correct |
9 |
Correct |
2 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 ms |
1408 KB |
Output is correct |
11 |
Correct |
2 ms |
1536 KB |
Output is correct |
12 |
Correct |
2 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1408 KB |
Output is correct |
14 |
Correct |
25 ms |
7544 KB |
Output is correct |
15 |
Correct |
3 ms |
4992 KB |
Output is correct |
16 |
Correct |
15 ms |
4352 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
30 ms |
8064 KB |
Output is correct |
19 |
Correct |
26 ms |
7936 KB |
Output is correct |
20 |
Correct |
26 ms |
7808 KB |
Output is correct |
21 |
Correct |
27 ms |
8056 KB |
Output is correct |
22 |
Correct |
24 ms |
7928 KB |
Output is correct |
23 |
Correct |
25 ms |
7808 KB |
Output is correct |
24 |
Correct |
27 ms |
8056 KB |
Output is correct |
25 |
Correct |
24 ms |
7936 KB |
Output is correct |
26 |
Correct |
25 ms |
7800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1536 KB |
Output is correct |
6 |
Correct |
2 ms |
1536 KB |
Output is correct |
7 |
Correct |
2 ms |
1408 KB |
Output is correct |
8 |
Correct |
2 ms |
1536 KB |
Output is correct |
9 |
Correct |
2 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 ms |
1408 KB |
Output is correct |
11 |
Correct |
2 ms |
1536 KB |
Output is correct |
12 |
Correct |
2 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1408 KB |
Output is correct |
14 |
Correct |
25 ms |
7544 KB |
Output is correct |
15 |
Correct |
3 ms |
4992 KB |
Output is correct |
16 |
Correct |
15 ms |
4352 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
30 ms |
8064 KB |
Output is correct |
19 |
Correct |
26 ms |
7936 KB |
Output is correct |
20 |
Correct |
26 ms |
7808 KB |
Output is correct |
21 |
Correct |
27 ms |
8056 KB |
Output is correct |
22 |
Correct |
24 ms |
7928 KB |
Output is correct |
23 |
Correct |
25 ms |
7808 KB |
Output is correct |
24 |
Correct |
27 ms |
8056 KB |
Output is correct |
25 |
Correct |
24 ms |
7936 KB |
Output is correct |
26 |
Correct |
25 ms |
7800 KB |
Output is correct |
27 |
Correct |
808 ms |
88096 KB |
Output is correct |
28 |
Correct |
16 ms |
25984 KB |
Output is correct |
29 |
Correct |
57 ms |
7800 KB |
Output is correct |
30 |
Correct |
3 ms |
640 KB |
Output is correct |
31 |
Correct |
586 ms |
72620 KB |
Output is correct |
32 |
Correct |
817 ms |
88500 KB |
Output is correct |
33 |
Correct |
781 ms |
88196 KB |
Output is correct |
34 |
Correct |
675 ms |
84216 KB |
Output is correct |
35 |
Correct |
803 ms |
88568 KB |
Output is correct |
36 |
Correct |
795 ms |
88312 KB |
Output is correct |
37 |
Correct |
856 ms |
88696 KB |
Output is correct |
38 |
Correct |
580 ms |
72568 KB |
Output is correct |
39 |
Correct |
552 ms |
72568 KB |
Output is correct |