#include <bits/stdc++.h>
using namespace std;
char c[3005][3005];
int d[3005][3005];
int r[3005][3005];
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> c[i][j];
}
}
for (int i = n-1; i >= 0; i--) {
for (int j = m-1; j >= 0; j--) {
d[i][j] = d[i+1][j];
if (c[i][j] == 'I') d[i][j]++;
r[i][j] = r[i][j+1];
if (c[i][j] == 'O') r[i][j]++;
}
}
long long sol = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (c[i][j] == 'J') {
sol += (long long)d[i][j] * (long long)r[i][j];
}
}
}
cout << sol;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1504 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1504 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
10 ms |
7508 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
5 ms |
4308 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
9 ms |
7896 KB |
Output is correct |
19 |
Correct |
8 ms |
7864 KB |
Output is correct |
20 |
Correct |
8 ms |
7764 KB |
Output is correct |
21 |
Correct |
9 ms |
8020 KB |
Output is correct |
22 |
Correct |
8 ms |
7932 KB |
Output is correct |
23 |
Correct |
9 ms |
7868 KB |
Output is correct |
24 |
Correct |
9 ms |
7892 KB |
Output is correct |
25 |
Correct |
8 ms |
7892 KB |
Output is correct |
26 |
Correct |
8 ms |
7852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1504 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
10 ms |
7508 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
5 ms |
4308 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
9 ms |
7896 KB |
Output is correct |
19 |
Correct |
8 ms |
7864 KB |
Output is correct |
20 |
Correct |
8 ms |
7764 KB |
Output is correct |
21 |
Correct |
9 ms |
8020 KB |
Output is correct |
22 |
Correct |
8 ms |
7932 KB |
Output is correct |
23 |
Correct |
9 ms |
7868 KB |
Output is correct |
24 |
Correct |
9 ms |
7892 KB |
Output is correct |
25 |
Correct |
8 ms |
7892 KB |
Output is correct |
26 |
Correct |
8 ms |
7852 KB |
Output is correct |
27 |
Correct |
206 ms |
88008 KB |
Output is correct |
28 |
Correct |
13 ms |
26044 KB |
Output is correct |
29 |
Correct |
14 ms |
7756 KB |
Output is correct |
30 |
Correct |
2 ms |
600 KB |
Output is correct |
31 |
Correct |
154 ms |
72484 KB |
Output is correct |
32 |
Correct |
165 ms |
88368 KB |
Output is correct |
33 |
Correct |
175 ms |
88176 KB |
Output is correct |
34 |
Correct |
196 ms |
84144 KB |
Output is correct |
35 |
Correct |
171 ms |
88364 KB |
Output is correct |
36 |
Correct |
165 ms |
88232 KB |
Output is correct |
37 |
Correct |
203 ms |
88504 KB |
Output is correct |
38 |
Correct |
119 ms |
72544 KB |
Output is correct |
39 |
Correct |
127 ms |
72216 KB |
Output is correct |