#include <bits/stdc++.h>
#define ll long long
#define pii pair <ll, ll>
#define st first
#define nd second
#define rep(i, n, m) for (ll i = (n); i <= (m); i ++)
#define rrep(i, m, n) for (ll i = (m); i >= (n); i --)
using namespace std;
const long long N = 3000 + 5;
ll n, m, f[N][N], g[N][N];
char a[N][N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
rep(i, 1, n) rep(j, 1, m)
cin >> a[i][j];
rep(i, 1, n) {
rep(j, 1, m) {
f[i][j] = f[i][j - 1] + (a[i][j] == 'O');
g[i][j] = g[i - 1][j] + (a[i][j] == 'I');
}
}
ll ans = 0;
rep(i, 1, n) rep(j, 1, m) if (a[i][j] == 'J') {
ll cntO = f[i][m] - f[i][j];
ll cntI = g[n][j] - g[i][j];
ans += cntO * cntI;
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
2 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 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 |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
2 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 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 |
7 ms |
8788 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
4 ms |
5192 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
9 ms |
9748 KB |
Output is correct |
19 |
Correct |
9 ms |
9540 KB |
Output is correct |
20 |
Correct |
9 ms |
9536 KB |
Output is correct |
21 |
Correct |
9 ms |
9684 KB |
Output is correct |
22 |
Correct |
9 ms |
9556 KB |
Output is correct |
23 |
Correct |
8 ms |
9556 KB |
Output is correct |
24 |
Correct |
9 ms |
9684 KB |
Output is correct |
25 |
Correct |
10 ms |
9556 KB |
Output is correct |
26 |
Correct |
10 ms |
9464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
2 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 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 |
7 ms |
8788 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
4 ms |
5192 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
9 ms |
9748 KB |
Output is correct |
19 |
Correct |
9 ms |
9540 KB |
Output is correct |
20 |
Correct |
9 ms |
9536 KB |
Output is correct |
21 |
Correct |
9 ms |
9684 KB |
Output is correct |
22 |
Correct |
9 ms |
9556 KB |
Output is correct |
23 |
Correct |
8 ms |
9556 KB |
Output is correct |
24 |
Correct |
9 ms |
9684 KB |
Output is correct |
25 |
Correct |
10 ms |
9556 KB |
Output is correct |
26 |
Correct |
10 ms |
9464 KB |
Output is correct |
27 |
Correct |
218 ms |
150264 KB |
Output is correct |
28 |
Correct |
14 ms |
26316 KB |
Output is correct |
29 |
Correct |
18 ms |
13516 KB |
Output is correct |
30 |
Correct |
2 ms |
724 KB |
Output is correct |
31 |
Correct |
196 ms |
125456 KB |
Output is correct |
32 |
Correct |
200 ms |
150636 KB |
Output is correct |
33 |
Correct |
192 ms |
149984 KB |
Output is correct |
34 |
Correct |
213 ms |
145484 KB |
Output is correct |
35 |
Correct |
201 ms |
150576 KB |
Output is correct |
36 |
Correct |
198 ms |
149952 KB |
Output is correct |
37 |
Correct |
234 ms |
150484 KB |
Output is correct |
38 |
Correct |
150 ms |
124980 KB |
Output is correct |
39 |
Correct |
147 ms |
124972 KB |
Output is correct |