#include <bits/stdc++.h>
#define int long long
#define pi pair <int, int>
#define ppi pair <pi, int>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << '\n'
#define debug2(x, y) cout << #x << ": " << x << ' ' << #y << ": " << y << '\n'
#define debug3(x, y, z) cout << #x << ": " << x << ' ' << #y << ": " << y << ' ' << #z << ": " << z << '\n'
using namespace std;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
const int inf = 1000000000;
int h, w, ans;
char grid[3005][3005];
int suffrow[3005][3005], suffcol[3005][3005]; //row count orb, column count ingot
signed main(){
ios::sync_with_stdio(0), cin.tie(0);
cin >> h >> w;
for(int i = 1; i <= h; i++) for(int j = 1; j <= w; j++) cin >> grid[i][j];
for(int i = 1; i <= h; i++) for(int j = w; j >= 1; j--){
suffrow[i][j] = suffrow[i][j+1];
if(grid[i][j] == 'O') suffrow[i][j]++;
}
for(int j = 1; j <= w; j++) for(int i = h; i >= 1; i--){
suffcol[j][i] = suffcol[j][i+1];
if(grid[i][j] == 'I') suffcol[j][i]++;
}
for(int i = 1; i < h; i++) for(int j = 1; j < w; j++){
if(grid[i][j] != 'J') continue;
ans += suffrow[i][j+1] * suffcol[j][i+1];
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1492 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1492 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1492 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1492 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1428 KB |
Output is correct |
14 |
Correct |
9 ms |
8368 KB |
Output is correct |
15 |
Correct |
2 ms |
3412 KB |
Output is correct |
16 |
Correct |
6 ms |
6100 KB |
Output is correct |
17 |
Correct |
1 ms |
1620 KB |
Output is correct |
18 |
Correct |
11 ms |
9684 KB |
Output is correct |
19 |
Correct |
10 ms |
9428 KB |
Output is correct |
20 |
Correct |
12 ms |
9516 KB |
Output is correct |
21 |
Correct |
12 ms |
9716 KB |
Output is correct |
22 |
Correct |
11 ms |
9420 KB |
Output is correct |
23 |
Correct |
11 ms |
9596 KB |
Output is correct |
24 |
Correct |
11 ms |
9640 KB |
Output is correct |
25 |
Correct |
10 ms |
9420 KB |
Output is correct |
26 |
Correct |
9 ms |
9556 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1492 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1492 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1428 KB |
Output is correct |
14 |
Correct |
9 ms |
8368 KB |
Output is correct |
15 |
Correct |
2 ms |
3412 KB |
Output is correct |
16 |
Correct |
6 ms |
6100 KB |
Output is correct |
17 |
Correct |
1 ms |
1620 KB |
Output is correct |
18 |
Correct |
11 ms |
9684 KB |
Output is correct |
19 |
Correct |
10 ms |
9428 KB |
Output is correct |
20 |
Correct |
12 ms |
9516 KB |
Output is correct |
21 |
Correct |
12 ms |
9716 KB |
Output is correct |
22 |
Correct |
11 ms |
9420 KB |
Output is correct |
23 |
Correct |
11 ms |
9596 KB |
Output is correct |
24 |
Correct |
11 ms |
9640 KB |
Output is correct |
25 |
Correct |
10 ms |
9420 KB |
Output is correct |
26 |
Correct |
9 ms |
9556 KB |
Output is correct |
27 |
Correct |
303 ms |
146340 KB |
Output is correct |
28 |
Correct |
11 ms |
16940 KB |
Output is correct |
29 |
Correct |
25 ms |
22228 KB |
Output is correct |
30 |
Correct |
7 ms |
9940 KB |
Output is correct |
31 |
Correct |
228 ms |
125364 KB |
Output is correct |
32 |
Correct |
261 ms |
149696 KB |
Output is correct |
33 |
Correct |
260 ms |
149964 KB |
Output is correct |
34 |
Correct |
259 ms |
135776 KB |
Output is correct |
35 |
Correct |
287 ms |
149808 KB |
Output is correct |
36 |
Correct |
253 ms |
149928 KB |
Output is correct |
37 |
Correct |
324 ms |
150252 KB |
Output is correct |
38 |
Correct |
187 ms |
124580 KB |
Output is correct |
39 |
Correct |
199 ms |
124940 KB |
Output is correct |