#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 3100;
char maze[maxn][maxn];
ll cnt[maxn];
int n, m;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
cin>>maze[i][j];
}
}
ll result = 0LL;
for(int i=n;i>=1;i--) {
// from down up
ll cntj = 0LL;
for(int j=1;j<=m;j++) {
if(maze[i][j] == 'J') cntj += cnt[j];
else if(maze[i][j] == 'O') {
// process
ll temp = 1LL * cntj;
result += temp;
}
else {
cnt[j]++;
}
}
}
cout<<result<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
640 KB |
Output is correct |
6 |
Correct |
3 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
640 KB |
Output is correct |
8 |
Correct |
2 ms |
640 KB |
Output is correct |
9 |
Correct |
3 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
640 KB |
Output is correct |
11 |
Correct |
3 ms |
640 KB |
Output is correct |
12 |
Correct |
2 ms |
640 KB |
Output is correct |
13 |
Correct |
3 ms |
640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
640 KB |
Output is correct |
6 |
Correct |
3 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
640 KB |
Output is correct |
8 |
Correct |
2 ms |
640 KB |
Output is correct |
9 |
Correct |
3 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
640 KB |
Output is correct |
11 |
Correct |
3 ms |
640 KB |
Output is correct |
12 |
Correct |
2 ms |
640 KB |
Output is correct |
13 |
Correct |
3 ms |
640 KB |
Output is correct |
14 |
Correct |
8 ms |
1920 KB |
Output is correct |
15 |
Correct |
3 ms |
1536 KB |
Output is correct |
16 |
Correct |
5 ms |
1152 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
9 ms |
1920 KB |
Output is correct |
19 |
Correct |
7 ms |
1920 KB |
Output is correct |
20 |
Correct |
7 ms |
1920 KB |
Output is correct |
21 |
Correct |
8 ms |
1792 KB |
Output is correct |
22 |
Correct |
6 ms |
1892 KB |
Output is correct |
23 |
Correct |
7 ms |
1792 KB |
Output is correct |
24 |
Correct |
8 ms |
1920 KB |
Output is correct |
25 |
Correct |
6 ms |
1792 KB |
Output is correct |
26 |
Correct |
6 ms |
1792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
640 KB |
Output is correct |
6 |
Correct |
3 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
640 KB |
Output is correct |
8 |
Correct |
2 ms |
640 KB |
Output is correct |
9 |
Correct |
3 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
640 KB |
Output is correct |
11 |
Correct |
3 ms |
640 KB |
Output is correct |
12 |
Correct |
2 ms |
640 KB |
Output is correct |
13 |
Correct |
3 ms |
640 KB |
Output is correct |
14 |
Correct |
8 ms |
1920 KB |
Output is correct |
15 |
Correct |
3 ms |
1536 KB |
Output is correct |
16 |
Correct |
5 ms |
1152 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
9 ms |
1920 KB |
Output is correct |
19 |
Correct |
7 ms |
1920 KB |
Output is correct |
20 |
Correct |
7 ms |
1920 KB |
Output is correct |
21 |
Correct |
8 ms |
1792 KB |
Output is correct |
22 |
Correct |
6 ms |
1892 KB |
Output is correct |
23 |
Correct |
7 ms |
1792 KB |
Output is correct |
24 |
Correct |
8 ms |
1920 KB |
Output is correct |
25 |
Correct |
6 ms |
1792 KB |
Output is correct |
26 |
Correct |
6 ms |
1792 KB |
Output is correct |
27 |
Correct |
176 ms |
9500 KB |
Output is correct |
28 |
Correct |
8 ms |
7424 KB |
Output is correct |
29 |
Correct |
10 ms |
1152 KB |
Output is correct |
30 |
Correct |
3 ms |
384 KB |
Output is correct |
31 |
Correct |
171 ms |
7928 KB |
Output is correct |
32 |
Correct |
130 ms |
9464 KB |
Output is correct |
33 |
Correct |
142 ms |
9524 KB |
Output is correct |
34 |
Correct |
176 ms |
9080 KB |
Output is correct |
35 |
Correct |
138 ms |
9464 KB |
Output is correct |
36 |
Correct |
122 ms |
9464 KB |
Output is correct |
37 |
Correct |
168 ms |
9464 KB |
Output is correct |
38 |
Correct |
89 ms |
7928 KB |
Output is correct |
39 |
Correct |
86 ms |
7932 KB |
Output is correct |