#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 3000 + 66;
string s[N];
ll d[N][N], r[N][N], Ans;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0 ; i < n ; ++ i) cin >> s[i];
for (int i = n - 1 ; i >= 0 ; -- i) {
for (int j = m - 1 ; j >= 0 ; -- j) {
r[i][j] = s[i][j] == 'O';
if (j + 1 < m) r[i][j] += r[i][j + 1];
d[i][j] = s[i][j] == 'I';
if (i + 1 < n) d[i][j] += d[i + 1][j];
Ans += (s[i][j] == 'J') * d[i][j] * r[i][j];
}
}
cout << Ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
1388 KB |
Output is correct |
6 |
Correct |
1 ms |
1388 KB |
Output is correct |
7 |
Correct |
1 ms |
1260 KB |
Output is correct |
8 |
Correct |
1 ms |
1388 KB |
Output is correct |
9 |
Correct |
1 ms |
1388 KB |
Output is correct |
10 |
Correct |
1 ms |
1260 KB |
Output is correct |
11 |
Correct |
1 ms |
1388 KB |
Output is correct |
12 |
Correct |
1 ms |
1388 KB |
Output is correct |
13 |
Correct |
1 ms |
1260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
1388 KB |
Output is correct |
6 |
Correct |
1 ms |
1388 KB |
Output is correct |
7 |
Correct |
1 ms |
1260 KB |
Output is correct |
8 |
Correct |
1 ms |
1388 KB |
Output is correct |
9 |
Correct |
1 ms |
1388 KB |
Output is correct |
10 |
Correct |
1 ms |
1260 KB |
Output is correct |
11 |
Correct |
1 ms |
1388 KB |
Output is correct |
12 |
Correct |
1 ms |
1388 KB |
Output is correct |
13 |
Correct |
1 ms |
1260 KB |
Output is correct |
14 |
Correct |
6 ms |
7916 KB |
Output is correct |
15 |
Correct |
2 ms |
3948 KB |
Output is correct |
16 |
Correct |
4 ms |
4844 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
6 ms |
8940 KB |
Output is correct |
19 |
Correct |
6 ms |
8684 KB |
Output is correct |
20 |
Correct |
6 ms |
8684 KB |
Output is correct |
21 |
Correct |
6 ms |
8940 KB |
Output is correct |
22 |
Correct |
6 ms |
8684 KB |
Output is correct |
23 |
Correct |
6 ms |
8684 KB |
Output is correct |
24 |
Correct |
6 ms |
8940 KB |
Output is correct |
25 |
Correct |
6 ms |
8684 KB |
Output is correct |
26 |
Correct |
6 ms |
8684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
1388 KB |
Output is correct |
6 |
Correct |
1 ms |
1388 KB |
Output is correct |
7 |
Correct |
1 ms |
1260 KB |
Output is correct |
8 |
Correct |
1 ms |
1388 KB |
Output is correct |
9 |
Correct |
1 ms |
1388 KB |
Output is correct |
10 |
Correct |
1 ms |
1260 KB |
Output is correct |
11 |
Correct |
1 ms |
1388 KB |
Output is correct |
12 |
Correct |
1 ms |
1388 KB |
Output is correct |
13 |
Correct |
1 ms |
1260 KB |
Output is correct |
14 |
Correct |
6 ms |
7916 KB |
Output is correct |
15 |
Correct |
2 ms |
3948 KB |
Output is correct |
16 |
Correct |
4 ms |
4844 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
6 ms |
8940 KB |
Output is correct |
19 |
Correct |
6 ms |
8684 KB |
Output is correct |
20 |
Correct |
6 ms |
8684 KB |
Output is correct |
21 |
Correct |
6 ms |
8940 KB |
Output is correct |
22 |
Correct |
6 ms |
8684 KB |
Output is correct |
23 |
Correct |
6 ms |
8684 KB |
Output is correct |
24 |
Correct |
6 ms |
8940 KB |
Output is correct |
25 |
Correct |
6 ms |
8684 KB |
Output is correct |
26 |
Correct |
6 ms |
8684 KB |
Output is correct |
27 |
Correct |
127 ms |
161932 KB |
Output is correct |
28 |
Correct |
11 ms |
19564 KB |
Output is correct |
29 |
Correct |
11 ms |
14060 KB |
Output is correct |
30 |
Correct |
2 ms |
876 KB |
Output is correct |
31 |
Correct |
98 ms |
131052 KB |
Output is correct |
32 |
Correct |
131 ms |
162796 KB |
Output is correct |
33 |
Correct |
166 ms |
162432 KB |
Output is correct |
34 |
Correct |
114 ms |
151916 KB |
Output is correct |
35 |
Correct |
135 ms |
162924 KB |
Output is correct |
36 |
Correct |
127 ms |
162540 KB |
Output is correct |
37 |
Correct |
129 ms |
162924 KB |
Output is correct |
38 |
Correct |
98 ms |
130156 KB |
Output is correct |
39 |
Correct |
98 ms |
130540 KB |
Output is correct |