#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 () {
ios_base::sync_with_stdio(false);
cin.tie(0);
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
1536 KB |
Output is correct |
6 |
Correct |
1 ms |
1536 KB |
Output is correct |
7 |
Correct |
1 ms |
1408 KB |
Output is correct |
8 |
Correct |
1 ms |
1536 KB |
Output is correct |
9 |
Correct |
1 ms |
1536 KB |
Output is correct |
10 |
Correct |
1 ms |
1408 KB |
Output is correct |
11 |
Correct |
1 ms |
1536 KB |
Output is correct |
12 |
Correct |
1 ms |
1536 KB |
Output is correct |
13 |
Correct |
1 ms |
1408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
1536 KB |
Output is correct |
6 |
Correct |
1 ms |
1536 KB |
Output is correct |
7 |
Correct |
1 ms |
1408 KB |
Output is correct |
8 |
Correct |
1 ms |
1536 KB |
Output is correct |
9 |
Correct |
1 ms |
1536 KB |
Output is correct |
10 |
Correct |
1 ms |
1408 KB |
Output is correct |
11 |
Correct |
1 ms |
1536 KB |
Output is correct |
12 |
Correct |
1 ms |
1536 KB |
Output is correct |
13 |
Correct |
1 ms |
1408 KB |
Output is correct |
14 |
Correct |
8 ms |
7296 KB |
Output is correct |
15 |
Correct |
3 ms |
4992 KB |
Output is correct |
16 |
Correct |
5 ms |
4224 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
11 ms |
7732 KB |
Output is correct |
19 |
Correct |
9 ms |
7680 KB |
Output is correct |
20 |
Correct |
9 ms |
7680 KB |
Output is correct |
21 |
Correct |
10 ms |
7808 KB |
Output is correct |
22 |
Correct |
10 ms |
7680 KB |
Output is correct |
23 |
Correct |
10 ms |
7680 KB |
Output is correct |
24 |
Correct |
11 ms |
7808 KB |
Output is correct |
25 |
Correct |
9 ms |
7680 KB |
Output is correct |
26 |
Correct |
9 ms |
7680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
1536 KB |
Output is correct |
6 |
Correct |
1 ms |
1536 KB |
Output is correct |
7 |
Correct |
1 ms |
1408 KB |
Output is correct |
8 |
Correct |
1 ms |
1536 KB |
Output is correct |
9 |
Correct |
1 ms |
1536 KB |
Output is correct |
10 |
Correct |
1 ms |
1408 KB |
Output is correct |
11 |
Correct |
1 ms |
1536 KB |
Output is correct |
12 |
Correct |
1 ms |
1536 KB |
Output is correct |
13 |
Correct |
1 ms |
1408 KB |
Output is correct |
14 |
Correct |
8 ms |
7296 KB |
Output is correct |
15 |
Correct |
3 ms |
4992 KB |
Output is correct |
16 |
Correct |
5 ms |
4224 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
11 ms |
7732 KB |
Output is correct |
19 |
Correct |
9 ms |
7680 KB |
Output is correct |
20 |
Correct |
9 ms |
7680 KB |
Output is correct |
21 |
Correct |
10 ms |
7808 KB |
Output is correct |
22 |
Correct |
10 ms |
7680 KB |
Output is correct |
23 |
Correct |
10 ms |
7680 KB |
Output is correct |
24 |
Correct |
11 ms |
7808 KB |
Output is correct |
25 |
Correct |
9 ms |
7680 KB |
Output is correct |
26 |
Correct |
9 ms |
7680 KB |
Output is correct |
27 |
Correct |
242 ms |
79660 KB |
Output is correct |
28 |
Correct |
18 ms |
25984 KB |
Output is correct |
29 |
Correct |
16 ms |
7168 KB |
Output is correct |
30 |
Correct |
1 ms |
640 KB |
Output is correct |
31 |
Correct |
180 ms |
66556 KB |
Output is correct |
32 |
Correct |
202 ms |
79736 KB |
Output is correct |
33 |
Correct |
203 ms |
79592 KB |
Output is correct |
34 |
Correct |
217 ms |
77052 KB |
Output is correct |
35 |
Correct |
207 ms |
79736 KB |
Output is correct |
36 |
Correct |
206 ms |
79604 KB |
Output is correct |
37 |
Correct |
266 ms |
79736 KB |
Output is correct |
38 |
Correct |
148 ms |
66552 KB |
Output is correct |
39 |
Correct |
145 ms |
66168 KB |
Output is correct |