#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int h, w;
cin >> h >> w;
vector<vector<char>> grid(h, vector<char>(w));
vector<int> countO(h), countI(w);
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j)
cin >> grid[i][j];
}
long long res = 0;
for (int i = h - 1; i >= 0; --i) {
for (int j = w - 1; j >= 0; --j) {
countO[i] += grid[i][j] == 'O';
countI[j] += grid[i][j] == 'I';
if (grid[i][j] == 'J')
res += countI[j] * countO[i];
}
}
cout << res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
3 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
468 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
712 KB |
Output is correct |
19 |
Correct |
4 ms |
596 KB |
Output is correct |
20 |
Correct |
5 ms |
592 KB |
Output is correct |
21 |
Correct |
5 ms |
588 KB |
Output is correct |
22 |
Correct |
4 ms |
596 KB |
Output is correct |
23 |
Correct |
4 ms |
596 KB |
Output is correct |
24 |
Correct |
5 ms |
596 KB |
Output is correct |
25 |
Correct |
5 ms |
696 KB |
Output is correct |
26 |
Correct |
6 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
3 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
468 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
712 KB |
Output is correct |
19 |
Correct |
4 ms |
596 KB |
Output is correct |
20 |
Correct |
5 ms |
592 KB |
Output is correct |
21 |
Correct |
5 ms |
588 KB |
Output is correct |
22 |
Correct |
4 ms |
596 KB |
Output is correct |
23 |
Correct |
4 ms |
596 KB |
Output is correct |
24 |
Correct |
5 ms |
596 KB |
Output is correct |
25 |
Correct |
5 ms |
696 KB |
Output is correct |
26 |
Correct |
6 ms |
596 KB |
Output is correct |
27 |
Correct |
148 ms |
8792 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
11 ms |
980 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
104 ms |
6656 KB |
Output is correct |
32 |
Correct |
134 ms |
9316 KB |
Output is correct |
33 |
Correct |
124 ms |
9328 KB |
Output is correct |
34 |
Correct |
114 ms |
7652 KB |
Output is correct |
35 |
Correct |
123 ms |
9300 KB |
Output is correct |
36 |
Correct |
123 ms |
9292 KB |
Output is correct |
37 |
Correct |
159 ms |
9356 KB |
Output is correct |
38 |
Correct |
87 ms |
6612 KB |
Output is correct |
39 |
Correct |
84 ms |
6612 KB |
Output is correct |