#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]){
int h, w;
cin >> h >> w;
char grid[h][w];
for(int i = 0; i < h; i++){
for(int k = 0; k < w; k++)
cin >> grid[i][k];
}
long long ingot[h][w] = {0}, orb[h][w] = {0};
for(int i = 0; i < w; i++){
int counter = 0;
for(int k = h - 1; k >= 0; k--){
if(grid[k][i] == 'I')
counter++;
ingot[k][i] = counter;
}
}
for(int i = 0; i < h; i++){
int counter = 0;
for(int k = w - 1; k >= 0; k--){
if(grid[i][k] == 'O')
counter++;
orb[i][k] = counter;
}
}
long long res = 0;
for(int i = 0; i < h; i++){
for(int k = 0; k < w; k++){
if(grid[i][k] == 'J')
res += orb[i][k] * ingot[i][k];
}
}
cout << res;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
6 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 |
6 ms |
504 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
6 ms |
504 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
6 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 |
6 ms |
504 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
6 ms |
504 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
504 KB |
Output is correct |
14 |
Correct |
23 ms |
3576 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
17 ms |
2424 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
28 ms |
4472 KB |
Output is correct |
19 |
Correct |
27 ms |
4344 KB |
Output is correct |
20 |
Correct |
27 ms |
4344 KB |
Output is correct |
21 |
Correct |
29 ms |
4728 KB |
Output is correct |
22 |
Correct |
27 ms |
4584 KB |
Output is correct |
23 |
Correct |
28 ms |
4600 KB |
Output is correct |
24 |
Correct |
29 ms |
4856 KB |
Output is correct |
25 |
Correct |
26 ms |
4472 KB |
Output is correct |
26 |
Correct |
27 ms |
4600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
6 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 |
6 ms |
504 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
6 ms |
504 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
504 KB |
Output is correct |
14 |
Correct |
23 ms |
3576 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
17 ms |
2424 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
28 ms |
4472 KB |
Output is correct |
19 |
Correct |
27 ms |
4344 KB |
Output is correct |
20 |
Correct |
27 ms |
4344 KB |
Output is correct |
21 |
Correct |
29 ms |
4728 KB |
Output is correct |
22 |
Correct |
27 ms |
4584 KB |
Output is correct |
23 |
Correct |
28 ms |
4600 KB |
Output is correct |
24 |
Correct |
29 ms |
4856 KB |
Output is correct |
25 |
Correct |
26 ms |
4472 KB |
Output is correct |
26 |
Correct |
27 ms |
4600 KB |
Output is correct |
27 |
Correct |
976 ms |
142572 KB |
Output is correct |
28 |
Correct |
7 ms |
760 KB |
Output is correct |
29 |
Correct |
65 ms |
11512 KB |
Output is correct |
30 |
Correct |
7 ms |
764 KB |
Output is correct |
31 |
Correct |
710 ms |
105080 KB |
Output is correct |
32 |
Correct |
1000 ms |
149504 KB |
Output is correct |
33 |
Execution timed out |
1066 ms |
150340 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |