#include <iostream>
using namespace std;
int main()
{
int H, W;
cin >> H >> W;
char T[H+1][W+1];
for(int i = 1; i <= H; i++) for(int j = 1; j <= W; j++)
{
cin >> T[i][j];
}
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++) O[i][j] = O[i][j-1] + (T[i][j] == 'O');
}
for(int j = 1; j <= W; j++)
{
I[0][j] = 0;
for(int i = 1; i <= H; i++)
{
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
4 ms |
380 KB |
Output is correct |
8 |
Correct |
4 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
4 ms |
380 KB |
Output is correct |
8 |
Correct |
4 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 |
24 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 |
2808 KB |
Output is correct |
19 |
Correct |
28 ms |
2684 KB |
Output is correct |
20 |
Correct |
29 ms |
2680 KB |
Output is correct |
21 |
Correct |
30 ms |
2808 KB |
Output is correct |
22 |
Correct |
29 ms |
2680 KB |
Output is correct |
23 |
Correct |
29 ms |
2680 KB |
Output is correct |
24 |
Correct |
31 ms |
2808 KB |
Output is correct |
25 |
Correct |
28 ms |
2680 KB |
Output is correct |
26 |
Correct |
31 ms |
2936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
4 ms |
380 KB |
Output is correct |
8 |
Correct |
4 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 |
24 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 |
2808 KB |
Output is correct |
19 |
Correct |
28 ms |
2684 KB |
Output is correct |
20 |
Correct |
29 ms |
2680 KB |
Output is correct |
21 |
Correct |
30 ms |
2808 KB |
Output is correct |
22 |
Correct |
29 ms |
2680 KB |
Output is correct |
23 |
Correct |
29 ms |
2680 KB |
Output is correct |
24 |
Correct |
31 ms |
2808 KB |
Output is correct |
25 |
Correct |
28 ms |
2680 KB |
Output is correct |
26 |
Correct |
31 ms |
2936 KB |
Output is correct |
27 |
Execution timed out |
1056 ms |
83680 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |