#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int h, w;
cin >> h >> w;
vector < long long > JOPairs(w);
long long ans = 0LL;
for (int i = 0; i < h; ++i) {
string s;
cin >> s;
int numO = 0;
for (int j = (int) s.size() - 1; j >= 0; --j) {
if (s[j] == 'O') {
++numO;
} else if (s[j] == 'J') {
JOPairs[j] += numO;
} else {
ans += JOPairs[j];
}
}
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
264 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
264 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
7 ms |
460 KB |
Output is correct |
15 |
Correct |
1 ms |
292 KB |
Output is correct |
16 |
Correct |
4 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
10 ms |
460 KB |
Output is correct |
19 |
Correct |
7 ms |
528 KB |
Output is correct |
20 |
Correct |
7 ms |
460 KB |
Output is correct |
21 |
Correct |
8 ms |
460 KB |
Output is correct |
22 |
Correct |
6 ms |
460 KB |
Output is correct |
23 |
Correct |
7 ms |
460 KB |
Output is correct |
24 |
Correct |
8 ms |
460 KB |
Output is correct |
25 |
Correct |
6 ms |
532 KB |
Output is correct |
26 |
Correct |
7 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
264 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
7 ms |
460 KB |
Output is correct |
15 |
Correct |
1 ms |
292 KB |
Output is correct |
16 |
Correct |
4 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
10 ms |
460 KB |
Output is correct |
19 |
Correct |
7 ms |
528 KB |
Output is correct |
20 |
Correct |
7 ms |
460 KB |
Output is correct |
21 |
Correct |
8 ms |
460 KB |
Output is correct |
22 |
Correct |
6 ms |
460 KB |
Output is correct |
23 |
Correct |
7 ms |
460 KB |
Output is correct |
24 |
Correct |
8 ms |
460 KB |
Output is correct |
25 |
Correct |
6 ms |
532 KB |
Output is correct |
26 |
Correct |
7 ms |
460 KB |
Output is correct |
27 |
Correct |
262 ms |
8596 KB |
Output is correct |
28 |
Correct |
2 ms |
204 KB |
Output is correct |
29 |
Correct |
16 ms |
940 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
188 ms |
6308 KB |
Output is correct |
32 |
Correct |
212 ms |
8988 KB |
Output is correct |
33 |
Correct |
221 ms |
8988 KB |
Output is correct |
34 |
Correct |
220 ms |
7364 KB |
Output is correct |
35 |
Correct |
219 ms |
8984 KB |
Output is correct |
36 |
Correct |
216 ms |
8992 KB |
Output is correct |
37 |
Correct |
273 ms |
9032 KB |
Output is correct |
38 |
Correct |
149 ms |
6340 KB |
Output is correct |
39 |
Correct |
153 ms |
6340 KB |
Output is correct |