#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 3030;
char c[N][N];
int qs[2][N][N];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int i = 1;i <= n;i++) {
cin >> (c[i] + 1);
for (int j = 1;j <= m;j++) {
qs[0][i][j] = qs[0][i][j - 1] + (c[i][j] == 'O');
qs[1][i][j] = qs[1][i - 1][j] + (c[i][j] == 'I');
}
}
ll ans = 0;
for (int i = 1;i < n;i++) {
for (int j = 1;j < m;j++) {
if (c[i][j] == 'J') {
ans += 1ll * (qs[0][i][m] - qs[0][i][j]) * (qs[1][n][j] - qs[1][i][j]);
}
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
7260 KB |
Output is correct |
6 |
Correct |
1 ms |
7384 KB |
Output is correct |
7 |
Correct |
1 ms |
5212 KB |
Output is correct |
8 |
Correct |
1 ms |
7516 KB |
Output is correct |
9 |
Correct |
1 ms |
7260 KB |
Output is correct |
10 |
Correct |
1 ms |
5212 KB |
Output is correct |
11 |
Correct |
1 ms |
7516 KB |
Output is correct |
12 |
Correct |
1 ms |
7260 KB |
Output is correct |
13 |
Correct |
1 ms |
5200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
7260 KB |
Output is correct |
6 |
Correct |
1 ms |
7384 KB |
Output is correct |
7 |
Correct |
1 ms |
5212 KB |
Output is correct |
8 |
Correct |
1 ms |
7516 KB |
Output is correct |
9 |
Correct |
1 ms |
7260 KB |
Output is correct |
10 |
Correct |
1 ms |
5212 KB |
Output is correct |
11 |
Correct |
1 ms |
7516 KB |
Output is correct |
12 |
Correct |
1 ms |
7260 KB |
Output is correct |
13 |
Correct |
1 ms |
5200 KB |
Output is correct |
14 |
Correct |
4 ms |
14168 KB |
Output is correct |
15 |
Correct |
2 ms |
10596 KB |
Output is correct |
16 |
Correct |
2 ms |
8796 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
5 ms |
14428 KB |
Output is correct |
19 |
Correct |
5 ms |
14428 KB |
Output is correct |
20 |
Correct |
4 ms |
14428 KB |
Output is correct |
21 |
Correct |
5 ms |
14548 KB |
Output is correct |
22 |
Correct |
4 ms |
14428 KB |
Output is correct |
23 |
Correct |
4 ms |
14428 KB |
Output is correct |
24 |
Correct |
4 ms |
14424 KB |
Output is correct |
25 |
Correct |
4 ms |
14428 KB |
Output is correct |
26 |
Correct |
4 ms |
14300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
7260 KB |
Output is correct |
6 |
Correct |
1 ms |
7384 KB |
Output is correct |
7 |
Correct |
1 ms |
5212 KB |
Output is correct |
8 |
Correct |
1 ms |
7516 KB |
Output is correct |
9 |
Correct |
1 ms |
7260 KB |
Output is correct |
10 |
Correct |
1 ms |
5212 KB |
Output is correct |
11 |
Correct |
1 ms |
7516 KB |
Output is correct |
12 |
Correct |
1 ms |
7260 KB |
Output is correct |
13 |
Correct |
1 ms |
5200 KB |
Output is correct |
14 |
Correct |
4 ms |
14168 KB |
Output is correct |
15 |
Correct |
2 ms |
10596 KB |
Output is correct |
16 |
Correct |
2 ms |
8796 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
5 ms |
14428 KB |
Output is correct |
19 |
Correct |
5 ms |
14428 KB |
Output is correct |
20 |
Correct |
4 ms |
14428 KB |
Output is correct |
21 |
Correct |
5 ms |
14548 KB |
Output is correct |
22 |
Correct |
4 ms |
14428 KB |
Output is correct |
23 |
Correct |
4 ms |
14428 KB |
Output is correct |
24 |
Correct |
4 ms |
14424 KB |
Output is correct |
25 |
Correct |
4 ms |
14428 KB |
Output is correct |
26 |
Correct |
4 ms |
14300 KB |
Output is correct |
27 |
Correct |
65 ms |
88484 KB |
Output is correct |
28 |
Correct |
8 ms |
47196 KB |
Output is correct |
29 |
Correct |
4 ms |
12636 KB |
Output is correct |
30 |
Correct |
1 ms |
2648 KB |
Output is correct |
31 |
Correct |
49 ms |
75808 KB |
Output is correct |
32 |
Correct |
48 ms |
88912 KB |
Output is correct |
33 |
Correct |
49 ms |
88660 KB |
Output is correct |
34 |
Correct |
59 ms |
85988 KB |
Output is correct |
35 |
Correct |
49 ms |
88912 KB |
Output is correct |
36 |
Correct |
47 ms |
88660 KB |
Output is correct |
37 |
Correct |
73 ms |
88968 KB |
Output is correct |
38 |
Correct |
38 ms |
75856 KB |
Output is correct |
39 |
Correct |
38 ms |
75720 KB |
Output is correct |