#include <bits/stdc++.h>
using namespace std;
void testCase() {
int n, m;
cin >> n >> m;
vector<string> a(n);
for (auto &s : a) {
cin >> s;
}
vector<vector<int>> ingot(n + 1, vector<int>(m + 1)), orb(n + 1, vector<int>(m + 1));
int64_t ans = 0;
for (int i = n - 1; i >= 0; --i) {
for (int j = m - 1; j >= 0; --j) {
if (a[i][j] == 'J') {
ans += (int64_t)ingot[i + 1][j] * orb[i][j + 1];
}
ingot[i][j] = ingot[i + 1][j] + (a[i][j] == 'I');
orb[i][j] = orb[i][j + 1] + (a[i][j] == 'O');
}
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int tests = 1;
for (int tc = 0; tc < tests; ++tc) {
testCase();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
0 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
0 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
0 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
0 ms |
336 KB |
Output is correct |
14 |
Correct |
3 ms |
2256 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
2 ms |
1596 KB |
Output is correct |
17 |
Correct |
0 ms |
336 KB |
Output is correct |
18 |
Correct |
3 ms |
2840 KB |
Output is correct |
19 |
Correct |
2 ms |
2620 KB |
Output is correct |
20 |
Correct |
2 ms |
2756 KB |
Output is correct |
21 |
Correct |
3 ms |
2768 KB |
Output is correct |
22 |
Correct |
2 ms |
2752 KB |
Output is correct |
23 |
Correct |
3 ms |
2756 KB |
Output is correct |
24 |
Correct |
3 ms |
2788 KB |
Output is correct |
25 |
Correct |
3 ms |
2640 KB |
Output is correct |
26 |
Correct |
3 ms |
2768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
0 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
0 ms |
336 KB |
Output is correct |
14 |
Correct |
3 ms |
2256 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
2 ms |
1596 KB |
Output is correct |
17 |
Correct |
0 ms |
336 KB |
Output is correct |
18 |
Correct |
3 ms |
2840 KB |
Output is correct |
19 |
Correct |
2 ms |
2620 KB |
Output is correct |
20 |
Correct |
2 ms |
2756 KB |
Output is correct |
21 |
Correct |
3 ms |
2768 KB |
Output is correct |
22 |
Correct |
2 ms |
2752 KB |
Output is correct |
23 |
Correct |
3 ms |
2756 KB |
Output is correct |
24 |
Correct |
3 ms |
2788 KB |
Output is correct |
25 |
Correct |
3 ms |
2640 KB |
Output is correct |
26 |
Correct |
3 ms |
2768 KB |
Output is correct |
27 |
Correct |
105 ms |
84552 KB |
Output is correct |
28 |
Correct |
1 ms |
720 KB |
Output is correct |
29 |
Correct |
6 ms |
6724 KB |
Output is correct |
30 |
Correct |
1 ms |
464 KB |
Output is correct |
31 |
Correct |
78 ms |
62224 KB |
Output is correct |
32 |
Correct |
77 ms |
89020 KB |
Output is correct |
33 |
Correct |
70 ms |
89288 KB |
Output is correct |
34 |
Correct |
71 ms |
72136 KB |
Output is correct |
35 |
Correct |
71 ms |
88908 KB |
Output is correct |
36 |
Correct |
71 ms |
89476 KB |
Output is correct |
37 |
Correct |
92 ms |
89552 KB |
Output is correct |
38 |
Correct |
50 ms |
61768 KB |
Output is correct |
39 |
Correct |
53 ms |
61984 KB |
Output is correct |