#include<bits/stdc++.h>
#define N 3010
#define int long long
using namespace std;
int n, m;
char c[N][N];
int dir[N][N], bai[N][N];
int32_t main(){
cin >> n >> m;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
cin >> c[i][j];
}
}
for(int i = 1;i <= n;i++){
for(int j = m;j > 0;j--){
dir[i][j] = dir[i][j+1] + (c[i][j] == 'O' ? 1 : 0);
}
}
for(int j = 1;j <= m;j++){
for(int i = n;i > 0;i--){
bai[i][j] = bai[i+1][j] + (c[i][j] == 'I' ? 1 : 0);
}
}
int res = 0;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
if(c[i][j] == 'J'){
res += dir[i][j]*bai[i][j];
}
}
}
cout << res << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
436 KB |
Output is correct |
5 |
Correct |
2 ms |
1464 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1464 KB |
Output is correct |
9 |
Correct |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
436 KB |
Output is correct |
5 |
Correct |
2 ms |
1464 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1464 KB |
Output is correct |
9 |
Correct |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
18 ms |
8916 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
11 ms |
5316 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
22 ms |
9988 KB |
Output is correct |
19 |
Correct |
18 ms |
9812 KB |
Output is correct |
20 |
Correct |
23 ms |
9684 KB |
Output is correct |
21 |
Correct |
22 ms |
9860 KB |
Output is correct |
22 |
Correct |
19 ms |
9812 KB |
Output is correct |
23 |
Correct |
19 ms |
9676 KB |
Output is correct |
24 |
Correct |
20 ms |
9900 KB |
Output is correct |
25 |
Correct |
18 ms |
9672 KB |
Output is correct |
26 |
Correct |
19 ms |
9760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
436 KB |
Output is correct |
5 |
Correct |
2 ms |
1464 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1464 KB |
Output is correct |
9 |
Correct |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
18 ms |
8916 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
11 ms |
5316 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
22 ms |
9988 KB |
Output is correct |
19 |
Correct |
18 ms |
9812 KB |
Output is correct |
20 |
Correct |
23 ms |
9684 KB |
Output is correct |
21 |
Correct |
22 ms |
9860 KB |
Output is correct |
22 |
Correct |
19 ms |
9812 KB |
Output is correct |
23 |
Correct |
19 ms |
9676 KB |
Output is correct |
24 |
Correct |
20 ms |
9900 KB |
Output is correct |
25 |
Correct |
18 ms |
9672 KB |
Output is correct |
26 |
Correct |
19 ms |
9760 KB |
Output is correct |
27 |
Correct |
741 ms |
158824 KB |
Output is correct |
28 |
Correct |
14 ms |
26324 KB |
Output is correct |
29 |
Correct |
46 ms |
13876 KB |
Output is correct |
30 |
Correct |
3 ms |
820 KB |
Output is correct |
31 |
Correct |
520 ms |
131620 KB |
Output is correct |
32 |
Correct |
714 ms |
159228 KB |
Output is correct |
33 |
Correct |
691 ms |
158752 KB |
Output is correct |
34 |
Correct |
590 ms |
152524 KB |
Output is correct |
35 |
Correct |
696 ms |
159236 KB |
Output is correct |
36 |
Correct |
682 ms |
158924 KB |
Output is correct |
37 |
Correct |
724 ms |
159328 KB |
Output is correct |
38 |
Correct |
493 ms |
130724 KB |
Output is correct |
39 |
Correct |
497 ms |
130952 KB |
Output is correct |