#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << " " <<
#define nl << "\n"
signed main(){
cin.tie(0)->sync_with_stdio(0);
int h, w; cin >> h >> w;
char g[h][w];
int orbs[h][w], ingots[h][w];
for(int i=0; i<h; ++i)
for(int j=0; j<w; ++j)
orbs[i][j] = ingots[i][j] = 0;
for(int i=0; i<h; ++i){
for(int j=0; j<w; ++j){
cin >> g[i][j];
if(g[i][j]=='O') ++orbs[i][j];
if(g[i][j]=='I') ++ingots[i][j];
}
}
for(int i=h-2; i>=0; --i){
for(int j=w-2; j>=0; --j){
orbs[i][j] += orbs[i][j+1];
ingots[i][j] += ingots[i+1][j];
}
}
int ans = 0;
for(int i=0; i<h; ++i){
for(int j=0; j<w; ++j){
if(g[i][j]=='J') ans += (orbs[i][j]*ingots[i][j]);
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
2 ms |
492 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
2 ms |
492 KB |
Output is correct |
12 |
Correct |
1 ms |
492 KB |
Output is correct |
13 |
Correct |
1 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
2 ms |
492 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
2 ms |
492 KB |
Output is correct |
12 |
Correct |
1 ms |
492 KB |
Output is correct |
13 |
Correct |
1 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
3692 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
5 ms |
2668 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
12 ms |
4716 KB |
Output is correct |
19 |
Correct |
9 ms |
4588 KB |
Output is correct |
20 |
Correct |
9 ms |
4588 KB |
Output is correct |
21 |
Correct |
14 ms |
4716 KB |
Output is correct |
22 |
Correct |
9 ms |
4588 KB |
Output is correct |
23 |
Correct |
8 ms |
4588 KB |
Output is correct |
24 |
Correct |
12 ms |
4716 KB |
Output is correct |
25 |
Correct |
10 ms |
4592 KB |
Output is correct |
26 |
Correct |
9 ms |
4588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
2 ms |
492 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
2 ms |
492 KB |
Output is correct |
12 |
Correct |
1 ms |
492 KB |
Output is correct |
13 |
Correct |
1 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
3692 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
5 ms |
2668 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
12 ms |
4716 KB |
Output is correct |
19 |
Correct |
9 ms |
4588 KB |
Output is correct |
20 |
Correct |
9 ms |
4588 KB |
Output is correct |
21 |
Correct |
14 ms |
4716 KB |
Output is correct |
22 |
Correct |
9 ms |
4588 KB |
Output is correct |
23 |
Correct |
8 ms |
4588 KB |
Output is correct |
24 |
Correct |
12 ms |
4716 KB |
Output is correct |
25 |
Correct |
10 ms |
4592 KB |
Output is correct |
26 |
Correct |
9 ms |
4588 KB |
Output is correct |
27 |
Correct |
357 ms |
144620 KB |
Output is correct |
28 |
Correct |
2 ms |
748 KB |
Output is correct |
29 |
Correct |
21 ms |
11756 KB |
Output is correct |
30 |
Correct |
2 ms |
748 KB |
Output is correct |
31 |
Correct |
262 ms |
106476 KB |
Output is correct |
32 |
Correct |
304 ms |
152428 KB |
Output is correct |
33 |
Correct |
259 ms |
152940 KB |
Output is correct |
34 |
Correct |
305 ms |
123136 KB |
Output is correct |
35 |
Correct |
308 ms |
152564 KB |
Output is correct |
36 |
Correct |
263 ms |
152940 KB |
Output is correct |
37 |
Correct |
383 ms |
153452 KB |
Output is correct |
38 |
Correct |
201 ms |
105708 KB |
Output is correct |
39 |
Correct |
181 ms |
105964 KB |
Output is correct |