#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
#define f first
#define s second
#define LOGN 21
const ll MOD = 1e9 + 7;
const ll MAXN = 3000 + 100;
#define int long long
vector<string> grid;
int toR[MAXN][MAXN], toD[MAXN][MAXN];
signed main() {
fast;
int H, W;
cin >> H >> W;
grid = vector<string>(H+1);
for (int i = 1; i <= H; i++) {
cin >> grid[i];
grid[i] = "#" + grid[i];
}
for (int i = 1; i <= H; i++) {
for (int j = W; j >= 1; j--)
toR[i][j] = toR[i][j+1] + (grid[i][j] == 'O');
}
for (int i = 1; i <= W; i++) {
for (int j = H; j >= 1; j--)
toD[j][i] = toD[j+1][i] + (grid[j][i] == 'I');
}
int ans = 0;
for (int i = 1; i <= H; i++) {
for (int j = 1; j <= W; j++) {
if (grid[i][j] == 'J')
ans += toR[i][j] * toD[i][j];
}
}
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 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 |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1368 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1428 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 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 |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1368 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1428 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1116 KB |
Output is correct |
14 |
Correct |
6 ms |
7636 KB |
Output is correct |
15 |
Correct |
2 ms |
3932 KB |
Output is correct |
16 |
Correct |
3 ms |
4700 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
8792 KB |
Output is correct |
19 |
Correct |
5 ms |
8540 KB |
Output is correct |
20 |
Correct |
5 ms |
8548 KB |
Output is correct |
21 |
Correct |
7 ms |
8956 KB |
Output is correct |
22 |
Correct |
5 ms |
8540 KB |
Output is correct |
23 |
Correct |
6 ms |
8540 KB |
Output is correct |
24 |
Correct |
7 ms |
8796 KB |
Output is correct |
25 |
Correct |
6 ms |
8532 KB |
Output is correct |
26 |
Correct |
6 ms |
8536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 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 |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1368 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1428 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1116 KB |
Output is correct |
14 |
Correct |
6 ms |
7636 KB |
Output is correct |
15 |
Correct |
2 ms |
3932 KB |
Output is correct |
16 |
Correct |
3 ms |
4700 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
8792 KB |
Output is correct |
19 |
Correct |
5 ms |
8540 KB |
Output is correct |
20 |
Correct |
5 ms |
8548 KB |
Output is correct |
21 |
Correct |
7 ms |
8956 KB |
Output is correct |
22 |
Correct |
5 ms |
8540 KB |
Output is correct |
23 |
Correct |
6 ms |
8540 KB |
Output is correct |
24 |
Correct |
7 ms |
8796 KB |
Output is correct |
25 |
Correct |
6 ms |
8532 KB |
Output is correct |
26 |
Correct |
6 ms |
8536 KB |
Output is correct |
27 |
Correct |
188 ms |
162640 KB |
Output is correct |
28 |
Correct |
9 ms |
19544 KB |
Output is correct |
29 |
Correct |
10 ms |
13912 KB |
Output is correct |
30 |
Correct |
1 ms |
952 KB |
Output is correct |
31 |
Correct |
143 ms |
130680 KB |
Output is correct |
32 |
Correct |
180 ms |
163668 KB |
Output is correct |
33 |
Correct |
178 ms |
163152 KB |
Output is correct |
34 |
Correct |
167 ms |
151304 KB |
Output is correct |
35 |
Correct |
178 ms |
163688 KB |
Output is correct |
36 |
Correct |
174 ms |
163176 KB |
Output is correct |
37 |
Correct |
181 ms |
163660 KB |
Output is correct |
38 |
Correct |
112 ms |
129620 KB |
Output is correct |
39 |
Correct |
112 ms |
129944 KB |
Output is correct |