#include<bits/stdc++.h>
using namespace std;
const int N = 3e3;
char v[N][N];
int cnt1[N][N];
int cnt2[N][N];
int main(){
int n,m;
cin>>n>>m;
for(int i = 0;i < n;i++){
for(int j = 0;j < m;j++){
cin>>v[i][j];
}
}
long long ans = 0;
for(int i = n - 1;i >= 0;i--){
for(int j = m - 1;j >= 0;j--){
cnt1[i][j] = (j == m - 1?0:cnt1[i][j + 1]) + (v[i][j] == 'O');
cnt2[i][j] = (i == n - 1?0:cnt2[i + 1][j]) + (v[i][j] == 'I');
if(v[i][j] == 'J')ans+=cnt1[i][j]*cnt2[i][j];
}
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1396 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1396 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1476 KB |
Output is correct |
14 |
Correct |
11 ms |
7512 KB |
Output is correct |
15 |
Correct |
2 ms |
5040 KB |
Output is correct |
16 |
Correct |
6 ms |
4188 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
12 ms |
7868 KB |
Output is correct |
19 |
Correct |
10 ms |
7772 KB |
Output is correct |
20 |
Correct |
12 ms |
7772 KB |
Output is correct |
21 |
Correct |
14 ms |
8028 KB |
Output is correct |
22 |
Correct |
12 ms |
7904 KB |
Output is correct |
23 |
Correct |
10 ms |
7748 KB |
Output is correct |
24 |
Correct |
15 ms |
8028 KB |
Output is correct |
25 |
Correct |
10 ms |
7848 KB |
Output is correct |
26 |
Correct |
10 ms |
7880 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1396 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1476 KB |
Output is correct |
14 |
Correct |
11 ms |
7512 KB |
Output is correct |
15 |
Correct |
2 ms |
5040 KB |
Output is correct |
16 |
Correct |
6 ms |
4188 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
12 ms |
7868 KB |
Output is correct |
19 |
Correct |
10 ms |
7772 KB |
Output is correct |
20 |
Correct |
12 ms |
7772 KB |
Output is correct |
21 |
Correct |
14 ms |
8028 KB |
Output is correct |
22 |
Correct |
12 ms |
7904 KB |
Output is correct |
23 |
Correct |
10 ms |
7748 KB |
Output is correct |
24 |
Correct |
15 ms |
8028 KB |
Output is correct |
25 |
Correct |
10 ms |
7848 KB |
Output is correct |
26 |
Correct |
10 ms |
7880 KB |
Output is correct |
27 |
Correct |
404 ms |
87780 KB |
Output is correct |
28 |
Correct |
10 ms |
25988 KB |
Output is correct |
29 |
Correct |
22 ms |
7732 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
232 ms |
72524 KB |
Output is correct |
32 |
Correct |
291 ms |
88408 KB |
Output is correct |
33 |
Correct |
295 ms |
87976 KB |
Output is correct |
34 |
Correct |
256 ms |
84140 KB |
Output is correct |
35 |
Correct |
317 ms |
88324 KB |
Output is correct |
36 |
Correct |
322 ms |
88148 KB |
Output is correct |
37 |
Correct |
333 ms |
88308 KB |
Output is correct |
38 |
Correct |
206 ms |
72408 KB |
Output is correct |
39 |
Correct |
206 ms |
72088 KB |
Output is correct |