#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int h, w;
vector<string> g;
vector<vector<ll>> a;
ll solve() {
ll ans = 0;
for (int i = 0; i < h; i++) {
ll c = 0;
for (int j = 0; j < w; j++) {
if (g[i][j] == 'J') c += a[h - 1][j] - a[i][j];
else if (g[i][j] == 'O') ans += c;
}
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> h >> w;
g.resize(h), a.resize(h, vector<ll>(w, 0));
for (int i = 0; i < h; i++) {
cin >> g[i];
for (int j = 0; j < w; j++) {
a[i][j] = (g[i][j] == 'I') + (i > 0 ? a[i - 1][j] : 0);
}
}
cout << solve() << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
3 ms |
2132 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
2 ms |
1492 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
3 ms |
2764 KB |
Output is correct |
19 |
Correct |
2 ms |
2632 KB |
Output is correct |
20 |
Correct |
2 ms |
2644 KB |
Output is correct |
21 |
Correct |
4 ms |
2772 KB |
Output is correct |
22 |
Correct |
3 ms |
2636 KB |
Output is correct |
23 |
Correct |
2 ms |
2644 KB |
Output is correct |
24 |
Correct |
3 ms |
2772 KB |
Output is correct |
25 |
Correct |
2 ms |
2640 KB |
Output is correct |
26 |
Correct |
2 ms |
2768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
3 ms |
2132 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
2 ms |
1492 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
3 ms |
2764 KB |
Output is correct |
19 |
Correct |
2 ms |
2632 KB |
Output is correct |
20 |
Correct |
2 ms |
2644 KB |
Output is correct |
21 |
Correct |
4 ms |
2772 KB |
Output is correct |
22 |
Correct |
3 ms |
2636 KB |
Output is correct |
23 |
Correct |
2 ms |
2644 KB |
Output is correct |
24 |
Correct |
3 ms |
2772 KB |
Output is correct |
25 |
Correct |
2 ms |
2640 KB |
Output is correct |
26 |
Correct |
2 ms |
2768 KB |
Output is correct |
27 |
Correct |
84 ms |
84420 KB |
Output is correct |
28 |
Correct |
1 ms |
596 KB |
Output is correct |
29 |
Correct |
6 ms |
6740 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
63 ms |
62164 KB |
Output is correct |
32 |
Correct |
71 ms |
88748 KB |
Output is correct |
33 |
Correct |
64 ms |
89160 KB |
Output is correct |
34 |
Correct |
71 ms |
71988 KB |
Output is correct |
35 |
Correct |
65 ms |
88852 KB |
Output is correct |
36 |
Correct |
71 ms |
89164 KB |
Output is correct |
37 |
Correct |
101 ms |
89344 KB |
Output is correct |
38 |
Correct |
46 ms |
61644 KB |
Output is correct |
39 |
Correct |
45 ms |
61940 KB |
Output is correct |