#include<bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define ff first
#define ss second
#define int long long
#define all(x) x.begin(), x.end()
const int maxn = 3e3 + 5;
int va[maxn];
char mtx[maxn][maxn];
int32_t main(){
int h, w; cin >> h >> w;
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
cin >> mtx[i][j];
}
}
int ans = 0;
for(int i = 0; i < w; i++){
for(int j = h-1; j >= 0; j--){
if(mtx[j][i]=='O') ans += va[j];
}
int ingots = 0;
for(int j = h-1; j >= 0; j--){
if(mtx[j][i]=='I') ingots++;
else if(mtx[j][i]=='J') va[j] += ingots;
}
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
596 KB |
Output is correct |
9 |
Correct |
2 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
596 KB |
Output is correct |
9 |
Correct |
2 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
15 ms |
1864 KB |
Output is correct |
15 |
Correct |
1 ms |
1464 KB |
Output is correct |
16 |
Correct |
9 ms |
1108 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
19 ms |
1816 KB |
Output is correct |
19 |
Correct |
16 ms |
1868 KB |
Output is correct |
20 |
Correct |
15 ms |
1852 KB |
Output is correct |
21 |
Correct |
20 ms |
1972 KB |
Output is correct |
22 |
Correct |
15 ms |
2020 KB |
Output is correct |
23 |
Correct |
15 ms |
1972 KB |
Output is correct |
24 |
Correct |
18 ms |
2004 KB |
Output is correct |
25 |
Correct |
15 ms |
2004 KB |
Output is correct |
26 |
Correct |
21 ms |
1916 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
596 KB |
Output is correct |
9 |
Correct |
2 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
15 ms |
1864 KB |
Output is correct |
15 |
Correct |
1 ms |
1464 KB |
Output is correct |
16 |
Correct |
9 ms |
1108 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
19 ms |
1816 KB |
Output is correct |
19 |
Correct |
16 ms |
1868 KB |
Output is correct |
20 |
Correct |
15 ms |
1852 KB |
Output is correct |
21 |
Correct |
20 ms |
1972 KB |
Output is correct |
22 |
Correct |
15 ms |
2020 KB |
Output is correct |
23 |
Correct |
15 ms |
1972 KB |
Output is correct |
24 |
Correct |
18 ms |
2004 KB |
Output is correct |
25 |
Correct |
15 ms |
2004 KB |
Output is correct |
26 |
Correct |
21 ms |
1916 KB |
Output is correct |
27 |
Correct |
624 ms |
9376 KB |
Output is correct |
28 |
Correct |
5 ms |
7124 KB |
Output is correct |
29 |
Correct |
42 ms |
1228 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
435 ms |
7916 KB |
Output is correct |
32 |
Correct |
600 ms |
9480 KB |
Output is correct |
33 |
Correct |
602 ms |
9472 KB |
Output is correct |
34 |
Correct |
520 ms |
9080 KB |
Output is correct |
35 |
Correct |
590 ms |
9516 KB |
Output is correct |
36 |
Correct |
586 ms |
9476 KB |
Output is correct |
37 |
Correct |
623 ms |
9696 KB |
Output is correct |
38 |
Correct |
399 ms |
7944 KB |
Output is correct |
39 |
Correct |
381 ms |
7888 KB |
Output is correct |