#include<bits/stdc++.h>
using namespace std;
const int MAX = 3e3 + 5;
int n, m, f[MAX];
char a[MAX][MAX];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= m; ++j){
cin >> a[i][j];
}
}
long long ans = 0;
for(int j = m; j >= 1; --j){
int sum = 0;
for(int i = 1; i <= n; ++i){
if(a[i][j] == 'J'){
sum += f[i];
}
else if(a[i][j] == 'O'){
++f[i];
}
else{
ans += sum;
}
}
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
344 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 |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2652 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
344 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 |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2652 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
3 ms |
2648 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
2 ms |
2648 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
2812 KB |
Output is correct |
19 |
Correct |
3 ms |
2908 KB |
Output is correct |
20 |
Correct |
3 ms |
2904 KB |
Output is correct |
21 |
Correct |
4 ms |
2780 KB |
Output is correct |
22 |
Correct |
3 ms |
2908 KB |
Output is correct |
23 |
Correct |
3 ms |
2808 KB |
Output is correct |
24 |
Correct |
4 ms |
2960 KB |
Output is correct |
25 |
Correct |
3 ms |
3064 KB |
Output is correct |
26 |
Correct |
3 ms |
2908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
344 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 |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2652 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
3 ms |
2648 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
2 ms |
2648 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
2812 KB |
Output is correct |
19 |
Correct |
3 ms |
2908 KB |
Output is correct |
20 |
Correct |
3 ms |
2904 KB |
Output is correct |
21 |
Correct |
4 ms |
2780 KB |
Output is correct |
22 |
Correct |
3 ms |
2908 KB |
Output is correct |
23 |
Correct |
3 ms |
2808 KB |
Output is correct |
24 |
Correct |
4 ms |
2960 KB |
Output is correct |
25 |
Correct |
3 ms |
3064 KB |
Output is correct |
26 |
Correct |
3 ms |
2908 KB |
Output is correct |
27 |
Correct |
118 ms |
17492 KB |
Output is correct |
28 |
Correct |
2 ms |
8792 KB |
Output is correct |
29 |
Correct |
6 ms |
3160 KB |
Output is correct |
30 |
Correct |
1 ms |
428 KB |
Output is correct |
31 |
Correct |
84 ms |
14832 KB |
Output is correct |
32 |
Correct |
80 ms |
17908 KB |
Output is correct |
33 |
Correct |
78 ms |
18004 KB |
Output is correct |
34 |
Correct |
105 ms |
16196 KB |
Output is correct |
35 |
Correct |
91 ms |
18004 KB |
Output is correct |
36 |
Correct |
83 ms |
17776 KB |
Output is correct |
37 |
Correct |
128 ms |
17900 KB |
Output is correct |
38 |
Correct |
64 ms |
14676 KB |
Output is correct |
39 |
Correct |
57 ms |
14840 KB |
Output is correct |