#include <bits/stdc++.h>
typedef long long ll;
int main() {
std::ios::sync_with_stdio(0);
int h, w; std::cin >> h >> w;
std::vector <std::vector <char>> g(3001, std::vector <char> (3001));
std::vector <std::vector <ll>> a(3001, std::vector <ll> (3001, 0)), b(a);
for (int i = 1; i <= h; i++)
for (int j = 1; j <= w; j++) {
std::cin >> g[i][j];
a[i][j] = a[i][j - 1];
b[i][j] = b[i - 1][j];
a[i][j] += g[i][j] == 'O';
b[i][j] += g[i][j] == 'I';
}
ll ans = 0;
for (int i = 1; i <= h; i++)
for (int j = 1; j <= w; j++)
if (g[i][j] == 'J')
ans += (a[i][w] - a[i][j]) * (b[h][j] - b[i][j]);
std::cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
88 ms |
150520 KB |
Output is correct |
2 |
Correct |
88 ms |
150392 KB |
Output is correct |
3 |
Correct |
89 ms |
150392 KB |
Output is correct |
4 |
Correct |
88 ms |
150392 KB |
Output is correct |
5 |
Correct |
90 ms |
150508 KB |
Output is correct |
6 |
Correct |
90 ms |
150520 KB |
Output is correct |
7 |
Correct |
90 ms |
150520 KB |
Output is correct |
8 |
Correct |
89 ms |
150520 KB |
Output is correct |
9 |
Correct |
89 ms |
150520 KB |
Output is correct |
10 |
Correct |
91 ms |
150504 KB |
Output is correct |
11 |
Correct |
91 ms |
150520 KB |
Output is correct |
12 |
Correct |
90 ms |
150520 KB |
Output is correct |
13 |
Correct |
88 ms |
150520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
88 ms |
150520 KB |
Output is correct |
2 |
Correct |
88 ms |
150392 KB |
Output is correct |
3 |
Correct |
89 ms |
150392 KB |
Output is correct |
4 |
Correct |
88 ms |
150392 KB |
Output is correct |
5 |
Correct |
90 ms |
150508 KB |
Output is correct |
6 |
Correct |
90 ms |
150520 KB |
Output is correct |
7 |
Correct |
90 ms |
150520 KB |
Output is correct |
8 |
Correct |
89 ms |
150520 KB |
Output is correct |
9 |
Correct |
89 ms |
150520 KB |
Output is correct |
10 |
Correct |
91 ms |
150504 KB |
Output is correct |
11 |
Correct |
91 ms |
150520 KB |
Output is correct |
12 |
Correct |
90 ms |
150520 KB |
Output is correct |
13 |
Correct |
88 ms |
150520 KB |
Output is correct |
14 |
Correct |
96 ms |
150776 KB |
Output is correct |
15 |
Correct |
89 ms |
150520 KB |
Output is correct |
16 |
Correct |
96 ms |
150780 KB |
Output is correct |
17 |
Correct |
89 ms |
150520 KB |
Output is correct |
18 |
Correct |
97 ms |
150652 KB |
Output is correct |
19 |
Correct |
96 ms |
150776 KB |
Output is correct |
20 |
Correct |
96 ms |
150776 KB |
Output is correct |
21 |
Correct |
101 ms |
150648 KB |
Output is correct |
22 |
Correct |
100 ms |
150648 KB |
Output is correct |
23 |
Correct |
97 ms |
150648 KB |
Output is correct |
24 |
Correct |
100 ms |
150776 KB |
Output is correct |
25 |
Correct |
97 ms |
150648 KB |
Output is correct |
26 |
Correct |
97 ms |
150648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
88 ms |
150520 KB |
Output is correct |
2 |
Correct |
88 ms |
150392 KB |
Output is correct |
3 |
Correct |
89 ms |
150392 KB |
Output is correct |
4 |
Correct |
88 ms |
150392 KB |
Output is correct |
5 |
Correct |
90 ms |
150508 KB |
Output is correct |
6 |
Correct |
90 ms |
150520 KB |
Output is correct |
7 |
Correct |
90 ms |
150520 KB |
Output is correct |
8 |
Correct |
89 ms |
150520 KB |
Output is correct |
9 |
Correct |
89 ms |
150520 KB |
Output is correct |
10 |
Correct |
91 ms |
150504 KB |
Output is correct |
11 |
Correct |
91 ms |
150520 KB |
Output is correct |
12 |
Correct |
90 ms |
150520 KB |
Output is correct |
13 |
Correct |
88 ms |
150520 KB |
Output is correct |
14 |
Correct |
96 ms |
150776 KB |
Output is correct |
15 |
Correct |
89 ms |
150520 KB |
Output is correct |
16 |
Correct |
96 ms |
150780 KB |
Output is correct |
17 |
Correct |
89 ms |
150520 KB |
Output is correct |
18 |
Correct |
97 ms |
150652 KB |
Output is correct |
19 |
Correct |
96 ms |
150776 KB |
Output is correct |
20 |
Correct |
96 ms |
150776 KB |
Output is correct |
21 |
Correct |
101 ms |
150648 KB |
Output is correct |
22 |
Correct |
100 ms |
150648 KB |
Output is correct |
23 |
Correct |
97 ms |
150648 KB |
Output is correct |
24 |
Correct |
100 ms |
150776 KB |
Output is correct |
25 |
Correct |
97 ms |
150648 KB |
Output is correct |
26 |
Correct |
97 ms |
150648 KB |
Output is correct |
27 |
Correct |
372 ms |
157560 KB |
Output is correct |
28 |
Correct |
94 ms |
150520 KB |
Output is correct |
29 |
Correct |
109 ms |
151160 KB |
Output is correct |
30 |
Correct |
90 ms |
150480 KB |
Output is correct |
31 |
Correct |
297 ms |
156536 KB |
Output is correct |
32 |
Correct |
357 ms |
157560 KB |
Output is correct |
33 |
Correct |
350 ms |
157560 KB |
Output is correct |
34 |
Correct |
329 ms |
157560 KB |
Output is correct |
35 |
Correct |
356 ms |
157560 KB |
Output is correct |
36 |
Correct |
346 ms |
157432 KB |
Output is correct |
37 |
Correct |
390 ms |
157720 KB |
Output is correct |
38 |
Correct |
270 ms |
156536 KB |
Output is correct |
39 |
Correct |
269 ms |
156536 KB |
Output is correct |