#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N = 3e3 + 7;
char c[N][N];
ll res[N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
ll ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> c[i][j];
}
}
for (int i = 0; i < n; i++) {
int cnt = 0;
for (int j = m - 1; j >= 0; j--) {
if (c[i][j] == 'O') {
cnt++;
}
if (c[i][j] == 'J') {
res[j] += cnt;
}
if (c[i][j] == 'I') {
ans += res[j];
}
}
}
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
632 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
5 ms |
632 KB |
Output is correct |
9 |
Correct |
5 ms |
632 KB |
Output is correct |
10 |
Correct |
5 ms |
760 KB |
Output is correct |
11 |
Correct |
5 ms |
632 KB |
Output is correct |
12 |
Correct |
5 ms |
632 KB |
Output is correct |
13 |
Correct |
5 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
632 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
5 ms |
632 KB |
Output is correct |
9 |
Correct |
5 ms |
632 KB |
Output is correct |
10 |
Correct |
5 ms |
760 KB |
Output is correct |
11 |
Correct |
5 ms |
632 KB |
Output is correct |
12 |
Correct |
5 ms |
632 KB |
Output is correct |
13 |
Correct |
5 ms |
632 KB |
Output is correct |
14 |
Correct |
9 ms |
2040 KB |
Output is correct |
15 |
Correct |
5 ms |
1528 KB |
Output is correct |
16 |
Correct |
8 ms |
1272 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
11 ms |
2040 KB |
Output is correct |
19 |
Correct |
9 ms |
2040 KB |
Output is correct |
20 |
Correct |
9 ms |
2040 KB |
Output is correct |
21 |
Correct |
12 ms |
2180 KB |
Output is correct |
22 |
Correct |
9 ms |
2040 KB |
Output is correct |
23 |
Correct |
9 ms |
2040 KB |
Output is correct |
24 |
Correct |
11 ms |
2040 KB |
Output is correct |
25 |
Correct |
9 ms |
2168 KB |
Output is correct |
26 |
Correct |
9 ms |
2040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
632 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
5 ms |
632 KB |
Output is correct |
9 |
Correct |
5 ms |
632 KB |
Output is correct |
10 |
Correct |
5 ms |
760 KB |
Output is correct |
11 |
Correct |
5 ms |
632 KB |
Output is correct |
12 |
Correct |
5 ms |
632 KB |
Output is correct |
13 |
Correct |
5 ms |
632 KB |
Output is correct |
14 |
Correct |
9 ms |
2040 KB |
Output is correct |
15 |
Correct |
5 ms |
1528 KB |
Output is correct |
16 |
Correct |
8 ms |
1272 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
11 ms |
2040 KB |
Output is correct |
19 |
Correct |
9 ms |
2040 KB |
Output is correct |
20 |
Correct |
9 ms |
2040 KB |
Output is correct |
21 |
Correct |
12 ms |
2180 KB |
Output is correct |
22 |
Correct |
9 ms |
2040 KB |
Output is correct |
23 |
Correct |
9 ms |
2040 KB |
Output is correct |
24 |
Correct |
11 ms |
2040 KB |
Output is correct |
25 |
Correct |
9 ms |
2168 KB |
Output is correct |
26 |
Correct |
9 ms |
2040 KB |
Output is correct |
27 |
Correct |
186 ms |
13176 KB |
Output is correct |
28 |
Correct |
9 ms |
7160 KB |
Output is correct |
29 |
Correct |
15 ms |
1784 KB |
Output is correct |
30 |
Correct |
5 ms |
376 KB |
Output is correct |
31 |
Correct |
138 ms |
11640 KB |
Output is correct |
32 |
Correct |
148 ms |
13048 KB |
Output is correct |
33 |
Correct |
136 ms |
13048 KB |
Output is correct |
34 |
Correct |
161 ms |
12664 KB |
Output is correct |
35 |
Correct |
139 ms |
13048 KB |
Output is correct |
36 |
Correct |
137 ms |
13048 KB |
Output is correct |
37 |
Correct |
201 ms |
13164 KB |
Output is correct |
38 |
Correct |
107 ms |
11640 KB |
Output is correct |
39 |
Correct |
94 ms |
11584 KB |
Output is correct |