#include <bits/stdc++.h>
#define MAX 1010
#define ll long long
using namespace std;
int n, m;
ll ans;
ll PO[MAX][MAX];
ll PI[MAX][MAX];
char v[MAX][MAX];
int main()
{
cin >> n >> m ;
for(int g = 1 ; g <= n ; g++)
for(int h = 1 ; h <= m ; h++)
cin >> v[g][h];
for(int g = 1 ; g <= n ; g++)
for(int h = m ; h > 0 ; h--)
PO[g][h] = PO[g][h + 1] + (v[g][h] == 'O') ;
for(int g = n ; g > 0 ; g--)
for(int h = 1 ; h <= m ; h++)
PI[g][h] = PI[g + 1][h] + (v[g][h] == 'I') ;
for(int g = 1 ; g <= n ; g++)
for(int h = 1 ; h <= m ; h++)
if(v[g][h] == 'J')
ans += PO[g][h] * PI[g][h];
cout << ans ;
}
# |
Verdict |
Execution time |
Memory |
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 |
4 ms |
1400 KB |
Output is correct |
6 |
Correct |
4 ms |
1272 KB |
Output is correct |
7 |
Correct |
4 ms |
1272 KB |
Output is correct |
8 |
Correct |
4 ms |
1400 KB |
Output is correct |
9 |
Correct |
4 ms |
1272 KB |
Output is correct |
10 |
Correct |
5 ms |
1272 KB |
Output is correct |
11 |
Correct |
4 ms |
1400 KB |
Output is correct |
12 |
Correct |
4 ms |
1400 KB |
Output is correct |
13 |
Correct |
4 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
4 ms |
1400 KB |
Output is correct |
6 |
Correct |
4 ms |
1272 KB |
Output is correct |
7 |
Correct |
4 ms |
1272 KB |
Output is correct |
8 |
Correct |
4 ms |
1400 KB |
Output is correct |
9 |
Correct |
4 ms |
1272 KB |
Output is correct |
10 |
Correct |
5 ms |
1272 KB |
Output is correct |
11 |
Correct |
4 ms |
1400 KB |
Output is correct |
12 |
Correct |
4 ms |
1400 KB |
Output is correct |
13 |
Correct |
4 ms |
1272 KB |
Output is correct |
14 |
Correct |
29 ms |
8056 KB |
Output is correct |
15 |
Correct |
7 ms |
4216 KB |
Output is correct |
16 |
Correct |
19 ms |
4728 KB |
Output is correct |
17 |
Correct |
3 ms |
504 KB |
Output is correct |
18 |
Correct |
35 ms |
8952 KB |
Output is correct |
19 |
Correct |
35 ms |
8828 KB |
Output is correct |
20 |
Correct |
35 ms |
8824 KB |
Output is correct |
21 |
Correct |
35 ms |
8952 KB |
Output is correct |
22 |
Correct |
33 ms |
8864 KB |
Output is correct |
23 |
Correct |
34 ms |
8824 KB |
Output is correct |
24 |
Correct |
36 ms |
8956 KB |
Output is correct |
25 |
Correct |
33 ms |
8824 KB |
Output is correct |
26 |
Correct |
34 ms |
8824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
4 ms |
1400 KB |
Output is correct |
6 |
Correct |
4 ms |
1272 KB |
Output is correct |
7 |
Correct |
4 ms |
1272 KB |
Output is correct |
8 |
Correct |
4 ms |
1400 KB |
Output is correct |
9 |
Correct |
4 ms |
1272 KB |
Output is correct |
10 |
Correct |
5 ms |
1272 KB |
Output is correct |
11 |
Correct |
4 ms |
1400 KB |
Output is correct |
12 |
Correct |
4 ms |
1400 KB |
Output is correct |
13 |
Correct |
4 ms |
1272 KB |
Output is correct |
14 |
Correct |
29 ms |
8056 KB |
Output is correct |
15 |
Correct |
7 ms |
4216 KB |
Output is correct |
16 |
Correct |
19 ms |
4728 KB |
Output is correct |
17 |
Correct |
3 ms |
504 KB |
Output is correct |
18 |
Correct |
35 ms |
8952 KB |
Output is correct |
19 |
Correct |
35 ms |
8828 KB |
Output is correct |
20 |
Correct |
35 ms |
8824 KB |
Output is correct |
21 |
Correct |
35 ms |
8952 KB |
Output is correct |
22 |
Correct |
33 ms |
8864 KB |
Output is correct |
23 |
Correct |
34 ms |
8824 KB |
Output is correct |
24 |
Correct |
36 ms |
8956 KB |
Output is correct |
25 |
Correct |
33 ms |
8824 KB |
Output is correct |
26 |
Correct |
34 ms |
8824 KB |
Output is correct |
27 |
Runtime error |
858 ms |
31028 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
28 |
Halted |
0 ms |
0 KB |
- |