#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
char a[n + 1][m + 1];
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= m; ++j)
cin >> a[i][j];
// find count o di kanan dan count i di bawah
int x[n + 2][m + 2], y[n + 2][m + 2];
memset(x, 0, sizeof(x));
memset(y, 0, sizeof(y));
for(int i = 1; i <= n; ++i) {
for(int j = m; j >= 1; --j) {
x[i][j] = x[i][j + 1] + (a[i][j] == 'O');
}
}
for(int i = n; i >= 1; --i) {
for(int j = 1; j <= m; ++j) {
y[i][j] = y[i + 1][j] + (a[i][j] == 'I');
}
}
long long ans = 0;
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
if(a[i][j] == 'J')
ans += 1ll * x[i][j] * y[i][j];
}
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
13 ms |
2072 KB |
Output is correct |
15 |
Correct |
1 ms |
300 KB |
Output is correct |
16 |
Correct |
9 ms |
1568 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
16 ms |
2708 KB |
Output is correct |
19 |
Correct |
15 ms |
2552 KB |
Output is correct |
20 |
Correct |
16 ms |
2636 KB |
Output is correct |
21 |
Correct |
18 ms |
2712 KB |
Output is correct |
22 |
Correct |
17 ms |
2612 KB |
Output is correct |
23 |
Correct |
18 ms |
2696 KB |
Output is correct |
24 |
Correct |
20 ms |
2740 KB |
Output is correct |
25 |
Correct |
16 ms |
2644 KB |
Output is correct |
26 |
Correct |
17 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
13 ms |
2072 KB |
Output is correct |
15 |
Correct |
1 ms |
300 KB |
Output is correct |
16 |
Correct |
9 ms |
1568 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
16 ms |
2708 KB |
Output is correct |
19 |
Correct |
15 ms |
2552 KB |
Output is correct |
20 |
Correct |
16 ms |
2636 KB |
Output is correct |
21 |
Correct |
18 ms |
2712 KB |
Output is correct |
22 |
Correct |
17 ms |
2612 KB |
Output is correct |
23 |
Correct |
18 ms |
2696 KB |
Output is correct |
24 |
Correct |
20 ms |
2740 KB |
Output is correct |
25 |
Correct |
16 ms |
2644 KB |
Output is correct |
26 |
Correct |
17 ms |
2636 KB |
Output is correct |
27 |
Correct |
583 ms |
82288 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
43 ms |
6648 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
448 ms |
61416 KB |
Output is correct |
32 |
Correct |
594 ms |
86012 KB |
Output is correct |
33 |
Correct |
600 ms |
86276 KB |
Output is correct |
34 |
Correct |
485 ms |
71308 KB |
Output is correct |
35 |
Correct |
593 ms |
86008 KB |
Output is correct |
36 |
Correct |
603 ms |
86272 KB |
Output is correct |
37 |
Correct |
623 ms |
86540 KB |
Output is correct |
38 |
Correct |
400 ms |
61004 KB |
Output is correct |
39 |
Correct |
422 ms |
61348 KB |
Output is correct |