#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 3005;
int n, m;
char a[N][N];
int d[2][N][N];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) {
cin >> a[i][j];
if (a[i][j] == 'O') d[0][i][j]++;
if (a[i][j] == 'I') d[1][i][j]++;
}
for (int i = 1; i <= n; i++) for (int j = m; j >= 1; j--) d[0][i][j] += d[0][i][j + 1];
for (int j = 1; j <= m; j++) for (int i = n; i >= 1; i--) d[1][i][j] += d[1][i + 1][j];
ll ans = 0;
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) {
if (a[i][j] == 'J')
ans += 1LL * d[0][i][j] * d[1][i][j];
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
360 KB |
Output is correct |
4 |
Correct |
1 ms |
332 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 |
1492 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 |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
360 KB |
Output is correct |
4 |
Correct |
1 ms |
332 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 |
1492 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 |
4944 KB |
Output is correct |
16 |
Correct |
5 ms |
4308 KB |
Output is correct |
17 |
Correct |
1 ms |
456 KB |
Output is correct |
18 |
Correct |
11 ms |
7940 KB |
Output is correct |
19 |
Correct |
9 ms |
7892 KB |
Output is correct |
20 |
Correct |
10 ms |
7764 KB |
Output is correct |
21 |
Correct |
14 ms |
8024 KB |
Output is correct |
22 |
Correct |
9 ms |
7892 KB |
Output is correct |
23 |
Correct |
8 ms |
7764 KB |
Output is correct |
24 |
Correct |
14 ms |
8020 KB |
Output is correct |
25 |
Correct |
9 ms |
7940 KB |
Output is correct |
26 |
Correct |
8 ms |
7764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
360 KB |
Output is correct |
4 |
Correct |
1 ms |
332 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 |
1492 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 |
4944 KB |
Output is correct |
16 |
Correct |
5 ms |
4308 KB |
Output is correct |
17 |
Correct |
1 ms |
456 KB |
Output is correct |
18 |
Correct |
11 ms |
7940 KB |
Output is correct |
19 |
Correct |
9 ms |
7892 KB |
Output is correct |
20 |
Correct |
10 ms |
7764 KB |
Output is correct |
21 |
Correct |
14 ms |
8024 KB |
Output is correct |
22 |
Correct |
9 ms |
7892 KB |
Output is correct |
23 |
Correct |
8 ms |
7764 KB |
Output is correct |
24 |
Correct |
14 ms |
8020 KB |
Output is correct |
25 |
Correct |
9 ms |
7940 KB |
Output is correct |
26 |
Correct |
8 ms |
7764 KB |
Output is correct |
27 |
Correct |
338 ms |
88016 KB |
Output is correct |
28 |
Correct |
12 ms |
25940 KB |
Output is correct |
29 |
Correct |
15 ms |
7784 KB |
Output is correct |
30 |
Correct |
1 ms |
596 KB |
Output is correct |
31 |
Correct |
247 ms |
72592 KB |
Output is correct |
32 |
Correct |
307 ms |
88484 KB |
Output is correct |
33 |
Correct |
234 ms |
88188 KB |
Output is correct |
34 |
Correct |
293 ms |
84216 KB |
Output is correct |
35 |
Correct |
294 ms |
88352 KB |
Output is correct |
36 |
Correct |
244 ms |
88148 KB |
Output is correct |
37 |
Correct |
362 ms |
88484 KB |
Output is correct |
38 |
Correct |
188 ms |
72436 KB |
Output is correct |
39 |
Correct |
170 ms |
72300 KB |
Output is correct |