// I wrote this code 4 u <3
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
signed main(int32_t argc, char *argv[]) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<string> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
vector<vector<ll>> prefX(m + 1, vector<ll>(n)), prefY(n + 1, vector<ll>(m));
for (int i = n - 1; i > -1; --i) {
for (int j = m - 1; j > -1; --j) {
prefX[j][i] = prefX[j + 1][i] + (a[i][j] == 'O');
prefY[i][j] = prefY[i + 1][j] + (a[i][j] == 'I');
}
}
ll ans = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
if (a[i][j] == 'J') {
ans += prefX[j + 1][i] * prefY[i + 1][j];
}
}
}
cout << ans;
}
/*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
3 ms |
3672 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
2652 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
4696 KB |
Output is correct |
19 |
Correct |
3 ms |
4700 KB |
Output is correct |
20 |
Correct |
3 ms |
4688 KB |
Output is correct |
21 |
Correct |
4 ms |
4700 KB |
Output is correct |
22 |
Correct |
3 ms |
4704 KB |
Output is correct |
23 |
Correct |
3 ms |
4816 KB |
Output is correct |
24 |
Correct |
4 ms |
4696 KB |
Output is correct |
25 |
Correct |
3 ms |
4952 KB |
Output is correct |
26 |
Correct |
3 ms |
4700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
3 ms |
3672 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
2652 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
4696 KB |
Output is correct |
19 |
Correct |
3 ms |
4700 KB |
Output is correct |
20 |
Correct |
3 ms |
4688 KB |
Output is correct |
21 |
Correct |
4 ms |
4700 KB |
Output is correct |
22 |
Correct |
3 ms |
4704 KB |
Output is correct |
23 |
Correct |
3 ms |
4816 KB |
Output is correct |
24 |
Correct |
4 ms |
4696 KB |
Output is correct |
25 |
Correct |
3 ms |
4952 KB |
Output is correct |
26 |
Correct |
3 ms |
4700 KB |
Output is correct |
27 |
Correct |
222 ms |
151280 KB |
Output is correct |
28 |
Correct |
1 ms |
860 KB |
Output is correct |
29 |
Correct |
9 ms |
11988 KB |
Output is correct |
30 |
Correct |
1 ms |
856 KB |
Output is correct |
31 |
Correct |
155 ms |
111188 KB |
Output is correct |
32 |
Correct |
196 ms |
159044 KB |
Output is correct |
33 |
Correct |
179 ms |
159744 KB |
Output is correct |
34 |
Correct |
185 ms |
128948 KB |
Output is correct |
35 |
Correct |
212 ms |
159156 KB |
Output is correct |
36 |
Correct |
188 ms |
159744 KB |
Output is correct |
37 |
Correct |
236 ms |
160464 KB |
Output is correct |
38 |
Correct |
131 ms |
110416 KB |
Output is correct |
39 |
Correct |
136 ms |
110952 KB |
Output is correct |