#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 3e3 + 5;
int n, m, arr[N][N];
vector<int> row[N][5], col[N][5];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
char ch;
cin >> ch;
if (ch == 'J') arr[i][j] = 0;
else if (ch == 'O') arr[i][j] = 1;
else arr[i][j] = 2;
row[i][arr[i][j]].push_back(j);
col[j][arr[i][j]].push_back(i);
}
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 3; j++) {
sort(row[i][j].begin(), row[i][j].end());
}
}
for (int j = 1; j <= m; j++) {
for (int i = 0; i < 3; i++) {
sort(col[j][i].begin(), col[j][i].end());
}
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (arr[i][j]) continue;
int cntO = row[i][1].end() - upper_bound(row[i][1].begin(), row[i][1].end(), j);
int cntI = col[j][2].end() - upper_bound(col[j][2].begin(), col[j][2].end(), i);
ans += cntO*cntI;
}
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
980 KB |
Output is correct |
2 |
Correct |
1 ms |
1032 KB |
Output is correct |
3 |
Correct |
1 ms |
1036 KB |
Output is correct |
4 |
Correct |
1 ms |
980 KB |
Output is correct |
5 |
Correct |
2 ms |
1748 KB |
Output is correct |
6 |
Correct |
1 ms |
1620 KB |
Output is correct |
7 |
Correct |
1 ms |
1620 KB |
Output is correct |
8 |
Correct |
2 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1620 KB |
Output is correct |
10 |
Correct |
1 ms |
1620 KB |
Output is correct |
11 |
Correct |
2 ms |
1808 KB |
Output is correct |
12 |
Correct |
1 ms |
1620 KB |
Output is correct |
13 |
Correct |
1 ms |
1620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
980 KB |
Output is correct |
2 |
Correct |
1 ms |
1032 KB |
Output is correct |
3 |
Correct |
1 ms |
1036 KB |
Output is correct |
4 |
Correct |
1 ms |
980 KB |
Output is correct |
5 |
Correct |
2 ms |
1748 KB |
Output is correct |
6 |
Correct |
1 ms |
1620 KB |
Output is correct |
7 |
Correct |
1 ms |
1620 KB |
Output is correct |
8 |
Correct |
2 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1620 KB |
Output is correct |
10 |
Correct |
1 ms |
1620 KB |
Output is correct |
11 |
Correct |
2 ms |
1808 KB |
Output is correct |
12 |
Correct |
1 ms |
1620 KB |
Output is correct |
13 |
Correct |
1 ms |
1620 KB |
Output is correct |
14 |
Correct |
17 ms |
9644 KB |
Output is correct |
15 |
Correct |
2 ms |
2900 KB |
Output is correct |
16 |
Correct |
9 ms |
6100 KB |
Output is correct |
17 |
Correct |
1 ms |
1108 KB |
Output is correct |
18 |
Correct |
23 ms |
11776 KB |
Output is correct |
19 |
Correct |
14 ms |
10420 KB |
Output is correct |
20 |
Correct |
12 ms |
9304 KB |
Output is correct |
21 |
Correct |
23 ms |
11784 KB |
Output is correct |
22 |
Correct |
19 ms |
10572 KB |
Output is correct |
23 |
Correct |
13 ms |
9236 KB |
Output is correct |
24 |
Correct |
23 ms |
10520 KB |
Output is correct |
25 |
Correct |
14 ms |
10136 KB |
Output is correct |
26 |
Correct |
12 ms |
9248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
980 KB |
Output is correct |
2 |
Correct |
1 ms |
1032 KB |
Output is correct |
3 |
Correct |
1 ms |
1036 KB |
Output is correct |
4 |
Correct |
1 ms |
980 KB |
Output is correct |
5 |
Correct |
2 ms |
1748 KB |
Output is correct |
6 |
Correct |
1 ms |
1620 KB |
Output is correct |
7 |
Correct |
1 ms |
1620 KB |
Output is correct |
8 |
Correct |
2 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1620 KB |
Output is correct |
10 |
Correct |
1 ms |
1620 KB |
Output is correct |
11 |
Correct |
2 ms |
1808 KB |
Output is correct |
12 |
Correct |
1 ms |
1620 KB |
Output is correct |
13 |
Correct |
1 ms |
1620 KB |
Output is correct |
14 |
Correct |
17 ms |
9644 KB |
Output is correct |
15 |
Correct |
2 ms |
2900 KB |
Output is correct |
16 |
Correct |
9 ms |
6100 KB |
Output is correct |
17 |
Correct |
1 ms |
1108 KB |
Output is correct |
18 |
Correct |
23 ms |
11776 KB |
Output is correct |
19 |
Correct |
14 ms |
10420 KB |
Output is correct |
20 |
Correct |
12 ms |
9304 KB |
Output is correct |
21 |
Correct |
23 ms |
11784 KB |
Output is correct |
22 |
Correct |
19 ms |
10572 KB |
Output is correct |
23 |
Correct |
13 ms |
9236 KB |
Output is correct |
24 |
Correct |
23 ms |
10520 KB |
Output is correct |
25 |
Correct |
14 ms |
10136 KB |
Output is correct |
26 |
Correct |
12 ms |
9248 KB |
Output is correct |
27 |
Correct |
909 ms |
241384 KB |
Output is correct |
28 |
Correct |
6 ms |
11220 KB |
Output is correct |
29 |
Correct |
37 ms |
21896 KB |
Output is correct |
30 |
Correct |
3 ms |
1788 KB |
Output is correct |
31 |
Correct |
783 ms |
193412 KB |
Output is correct |
32 |
Correct |
584 ms |
262528 KB |
Output is correct |
33 |
Correct |
573 ms |
269644 KB |
Output is correct |
34 |
Correct |
756 ms |
214000 KB |
Output is correct |
35 |
Correct |
689 ms |
265468 KB |
Output is correct |
36 |
Correct |
577 ms |
269708 KB |
Output is correct |
37 |
Runtime error |
370 ms |
274432 KB |
Execution killed with signal 9 |
38 |
Halted |
0 ms |
0 KB |
- |