#include <iostream>
using namespace std;
int main()
{
int H, W;
cin >> H >> W;
char T[H+1][W+1];
int O[H+1][W+1], I[H+1][W+1];
for(int i = 1; i <= H; i++) O[i][0] = 0;
for(int j = 1; j <= W; j++) I[0][j] = 0;
for(int i = 1; i <= H; i++) for(int j = 1; j <= W; j++)
{
cin >> T[i][j];
O[i][j] = O[i][j-1] + (T[i][j] == 'O');
I[i][j] = I[i-1][j] + (T[i][j] == 'I');
}
long long res = 0;
for(int i = 1; i <= H; i++) for(int j = 1; j <= W; j++)
{
if(T[i][j] != 'J') continue;
res += (O[i][W] - O[i][j]) * (I[H][j] - I[i][j]);
}
cout << res << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
23 ms |
2168 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
16 ms |
1528 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
30 ms |
2772 KB |
Output is correct |
19 |
Correct |
28 ms |
2680 KB |
Output is correct |
20 |
Correct |
28 ms |
2680 KB |
Output is correct |
21 |
Correct |
30 ms |
2808 KB |
Output is correct |
22 |
Correct |
28 ms |
2680 KB |
Output is correct |
23 |
Correct |
28 ms |
2744 KB |
Output is correct |
24 |
Correct |
30 ms |
2808 KB |
Output is correct |
25 |
Correct |
30 ms |
2632 KB |
Output is correct |
26 |
Correct |
71 ms |
2684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
23 ms |
2168 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
16 ms |
1528 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
30 ms |
2772 KB |
Output is correct |
19 |
Correct |
28 ms |
2680 KB |
Output is correct |
20 |
Correct |
28 ms |
2680 KB |
Output is correct |
21 |
Correct |
30 ms |
2808 KB |
Output is correct |
22 |
Correct |
28 ms |
2680 KB |
Output is correct |
23 |
Correct |
28 ms |
2744 KB |
Output is correct |
24 |
Correct |
30 ms |
2808 KB |
Output is correct |
25 |
Correct |
30 ms |
2632 KB |
Output is correct |
26 |
Correct |
71 ms |
2684 KB |
Output is correct |
27 |
Correct |
933 ms |
76876 KB |
Output is correct |
28 |
Correct |
5 ms |
504 KB |
Output is correct |
29 |
Correct |
70 ms |
6648 KB |
Output is correct |
30 |
Correct |
5 ms |
632 KB |
Output is correct |
31 |
Correct |
688 ms |
61688 KB |
Output is correct |
32 |
Correct |
954 ms |
87992 KB |
Output is correct |
33 |
Correct |
951 ms |
88216 KB |
Output is correct |
34 |
Correct |
797 ms |
71548 KB |
Output is correct |
35 |
Correct |
956 ms |
87880 KB |
Output is correct |
36 |
Correct |
953 ms |
88184 KB |
Output is correct |
37 |
Correct |
997 ms |
88568 KB |
Output is correct |
38 |
Correct |
696 ms |
61024 KB |
Output is correct |
39 |
Correct |
661 ms |
61288 KB |
Output is correct |