#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mxN=3e3;
int h, w, a[mxN];
string g[mxN];
ll ans;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> h >> w;
for(int i=0; i<h; ++i)
cin >> g[i];
for(int i=h-1; i>=0; --i) {
for(int j=w-1, b=0; j>=0; --j) {
if(g[i][j]=='J')
ans+=a[j]*b;
else if(g[i][j]=='O')
++b;
else
++a[j];
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
3 ms |
512 KB |
Output is correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
3 ms |
512 KB |
Output is correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
14 |
Correct |
4 ms |
768 KB |
Output is correct |
15 |
Correct |
3 ms |
512 KB |
Output is correct |
16 |
Correct |
3 ms |
768 KB |
Output is correct |
17 |
Correct |
2 ms |
640 KB |
Output is correct |
18 |
Correct |
5 ms |
896 KB |
Output is correct |
19 |
Correct |
3 ms |
896 KB |
Output is correct |
20 |
Correct |
3 ms |
896 KB |
Output is correct |
21 |
Correct |
4 ms |
896 KB |
Output is correct |
22 |
Correct |
3 ms |
896 KB |
Output is correct |
23 |
Correct |
3 ms |
896 KB |
Output is correct |
24 |
Correct |
4 ms |
896 KB |
Output is correct |
25 |
Correct |
3 ms |
896 KB |
Output is correct |
26 |
Correct |
3 ms |
896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
3 ms |
512 KB |
Output is correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
14 |
Correct |
4 ms |
768 KB |
Output is correct |
15 |
Correct |
3 ms |
512 KB |
Output is correct |
16 |
Correct |
3 ms |
768 KB |
Output is correct |
17 |
Correct |
2 ms |
640 KB |
Output is correct |
18 |
Correct |
5 ms |
896 KB |
Output is correct |
19 |
Correct |
3 ms |
896 KB |
Output is correct |
20 |
Correct |
3 ms |
896 KB |
Output is correct |
21 |
Correct |
4 ms |
896 KB |
Output is correct |
22 |
Correct |
3 ms |
896 KB |
Output is correct |
23 |
Correct |
3 ms |
896 KB |
Output is correct |
24 |
Correct |
4 ms |
896 KB |
Output is correct |
25 |
Correct |
3 ms |
896 KB |
Output is correct |
26 |
Correct |
3 ms |
896 KB |
Output is correct |
27 |
Correct |
82 ms |
17784 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
4 ms |
1792 KB |
Output is correct |
30 |
Correct |
2 ms |
512 KB |
Output is correct |
31 |
Correct |
62 ms |
13176 KB |
Output is correct |
32 |
Correct |
43 ms |
18000 KB |
Output is correct |
33 |
Correct |
34 ms |
18168 KB |
Output is correct |
34 |
Correct |
68 ms |
15232 KB |
Output is correct |
35 |
Correct |
40 ms |
18040 KB |
Output is correct |
36 |
Correct |
34 ms |
17912 KB |
Output is correct |
37 |
Correct |
82 ms |
17920 KB |
Output is correct |
38 |
Correct |
27 ms |
13056 KB |
Output is correct |
39 |
Correct |
24 ms |
13184 KB |
Output is correct |