#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int h, w;
cin >> h >> w;
vector<vector<char>> grid(h+1, vector<char>(w+1));
vector<int> orb(h+1), ingot(w+1);
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
cin >> grid[i][j];
if (grid[i][j] == 'O')
orb[i]++;
else if (grid[i][j] == 'I')
ingot[j]++;
}
}
ll ans = 0;
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
if (grid[i][j] == 'J')
ans += 1ll*orb[i]*ingot[j];
else if (grid[i][j] == 'O')
orb[i]--;
else
ingot[j]--;
}
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
5 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
720 KB |
Output is correct |
19 |
Correct |
3 ms |
608 KB |
Output is correct |
20 |
Correct |
3 ms |
604 KB |
Output is correct |
21 |
Correct |
6 ms |
856 KB |
Output is correct |
22 |
Correct |
3 ms |
872 KB |
Output is correct |
23 |
Correct |
3 ms |
832 KB |
Output is correct |
24 |
Correct |
8 ms |
840 KB |
Output is correct |
25 |
Correct |
4 ms |
840 KB |
Output is correct |
26 |
Correct |
3 ms |
968 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
5 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
720 KB |
Output is correct |
19 |
Correct |
3 ms |
608 KB |
Output is correct |
20 |
Correct |
3 ms |
604 KB |
Output is correct |
21 |
Correct |
6 ms |
856 KB |
Output is correct |
22 |
Correct |
3 ms |
872 KB |
Output is correct |
23 |
Correct |
3 ms |
832 KB |
Output is correct |
24 |
Correct |
8 ms |
840 KB |
Output is correct |
25 |
Correct |
4 ms |
840 KB |
Output is correct |
26 |
Correct |
3 ms |
968 KB |
Output is correct |
27 |
Correct |
233 ms |
17204 KB |
Output is correct |
28 |
Correct |
1 ms |
616 KB |
Output is correct |
29 |
Correct |
8 ms |
1744 KB |
Output is correct |
30 |
Correct |
1 ms |
524 KB |
Output is correct |
31 |
Correct |
165 ms |
12684 KB |
Output is correct |
32 |
Correct |
107 ms |
17880 KB |
Output is correct |
33 |
Correct |
100 ms |
17960 KB |
Output is correct |
34 |
Correct |
186 ms |
14556 KB |
Output is correct |
35 |
Correct |
101 ms |
18028 KB |
Output is correct |
36 |
Correct |
85 ms |
17952 KB |
Output is correct |
37 |
Correct |
213 ms |
18112 KB |
Output is correct |
38 |
Correct |
91 ms |
12624 KB |
Output is correct |
39 |
Correct |
60 ms |
12636 KB |
Output is correct |