#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(int argc, char const *argv[]){
cin.tie(0), ios::sync_with_stdio(0);
ll h, w;
cin >> h >> w;
char grid[h][w];
for(ll i = 0; i < h; i++){
for(ll k = 0; k < w; k++)
cin >> grid[i][k];
}
ll ingot[h][w] = {0}, orb[h][w] = {0};
for(ll i = 0; i < w; i++){
ll counter = 0;
for(ll k = h - 1; k >= 0; k--){
if(grid[k][i] == 'I')
counter++;
ingot[k][i] = counter;
}
}
for(ll i = 0; i < h; i++){
ll counter = 0;
for(ll k = w - 1; k >= 0; k--){
if(grid[i][k] == 'O')
counter++;
orb[i][k] = counter;
}
}
ll res = 0;
for(ll i = 0; i < h; i++){
for(ll k = 0; k < w; k++){
if(grid[i][k] == 'J')
res += orb[i][k] * ingot[i][k];
}
}
cout << res;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
380 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
504 KB |
Output is correct |
6 |
Correct |
5 ms |
504 KB |
Output is correct |
7 |
Correct |
5 ms |
504 KB |
Output is correct |
8 |
Correct |
5 ms |
504 KB |
Output is correct |
9 |
Correct |
5 ms |
504 KB |
Output is correct |
10 |
Correct |
5 ms |
504 KB |
Output is correct |
11 |
Correct |
6 ms |
504 KB |
Output is correct |
12 |
Correct |
5 ms |
504 KB |
Output is correct |
13 |
Correct |
5 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
380 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
504 KB |
Output is correct |
6 |
Correct |
5 ms |
504 KB |
Output is correct |
7 |
Correct |
5 ms |
504 KB |
Output is correct |
8 |
Correct |
5 ms |
504 KB |
Output is correct |
9 |
Correct |
5 ms |
504 KB |
Output is correct |
10 |
Correct |
5 ms |
504 KB |
Output is correct |
11 |
Correct |
6 ms |
504 KB |
Output is correct |
12 |
Correct |
5 ms |
504 KB |
Output is correct |
13 |
Correct |
5 ms |
504 KB |
Output is correct |
14 |
Correct |
10 ms |
3576 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
8 ms |
2424 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
12 ms |
4472 KB |
Output is correct |
19 |
Correct |
11 ms |
4344 KB |
Output is correct |
20 |
Correct |
11 ms |
4344 KB |
Output is correct |
21 |
Correct |
12 ms |
4472 KB |
Output is correct |
22 |
Correct |
11 ms |
4344 KB |
Output is correct |
23 |
Correct |
12 ms |
4344 KB |
Output is correct |
24 |
Correct |
13 ms |
4472 KB |
Output is correct |
25 |
Correct |
11 ms |
4344 KB |
Output is correct |
26 |
Correct |
11 ms |
4348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
380 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
504 KB |
Output is correct |
6 |
Correct |
5 ms |
504 KB |
Output is correct |
7 |
Correct |
5 ms |
504 KB |
Output is correct |
8 |
Correct |
5 ms |
504 KB |
Output is correct |
9 |
Correct |
5 ms |
504 KB |
Output is correct |
10 |
Correct |
5 ms |
504 KB |
Output is correct |
11 |
Correct |
6 ms |
504 KB |
Output is correct |
12 |
Correct |
5 ms |
504 KB |
Output is correct |
13 |
Correct |
5 ms |
504 KB |
Output is correct |
14 |
Correct |
10 ms |
3576 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
8 ms |
2424 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
12 ms |
4472 KB |
Output is correct |
19 |
Correct |
11 ms |
4344 KB |
Output is correct |
20 |
Correct |
11 ms |
4344 KB |
Output is correct |
21 |
Correct |
12 ms |
4472 KB |
Output is correct |
22 |
Correct |
11 ms |
4344 KB |
Output is correct |
23 |
Correct |
12 ms |
4344 KB |
Output is correct |
24 |
Correct |
13 ms |
4472 KB |
Output is correct |
25 |
Correct |
11 ms |
4344 KB |
Output is correct |
26 |
Correct |
11 ms |
4348 KB |
Output is correct |
27 |
Correct |
424 ms |
142072 KB |
Output is correct |
28 |
Correct |
5 ms |
760 KB |
Output is correct |
29 |
Correct |
22 ms |
11128 KB |
Output is correct |
30 |
Correct |
5 ms |
760 KB |
Output is correct |
31 |
Correct |
299 ms |
104312 KB |
Output is correct |
32 |
Correct |
420 ms |
148984 KB |
Output is correct |
33 |
Correct |
412 ms |
149624 KB |
Output is correct |
34 |
Correct |
349 ms |
121696 KB |
Output is correct |
35 |
Correct |
416 ms |
149624 KB |
Output is correct |
36 |
Correct |
416 ms |
149880 KB |
Output is correct |
37 |
Correct |
458 ms |
150264 KB |
Output is correct |
38 |
Correct |
278 ms |
103800 KB |
Output is correct |
39 |
Correct |
275 ms |
104312 KB |
Output is correct |