#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
template<typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using max_heap = priority_queue<T, vector<T>, less<T>>;
using int64 = long long;
using ld = long double;
constexpr int kInf = 1e9 + 10;
constexpr int64 kInf64 = 1e15 + 10;
constexpr int kMod = 1e9 + 7;
int check(const vector<vector<int>> &a, const int k) {
deque<int> d;
auto add = [&](const int i) {
for (const int x : a[i]) {
d.push_back(x);
}
};
auto rem = [&](const int i) {
for (const int x : a[i]) {
assert(d.front() == x);
d.pop_front();
}
};
auto get_vec = [&]() -> vector<int> {
return {d.begin(), d.end()};
};
for (int i = 0; i < k; i++) {
add(i);
}
vector<int> consider;
for (int i = k; i < a.size(); i++) {
add(i);
if (not d.empty()) {
const int x = add_or(get_vec());
const int y = add_xor(get_vec());
consider.push_back(add_xor({x, y}));
}
rem(i - k);
}
assert(not consider.empty());
return add_or(consider);
}
void construct_network(int H, int W, int K) {
if (H * W == 2) {
assert(K == 1);
add_and({0, 1});
return;
}
auto cell = [&](const int row, const int col) {
assert(0 <= row and row < H);
assert(0 <= col and col < W);
return row * W + col;
};
vector<vector<int>> left_diagonal(H + W);
for (int sum = 0; sum < H + W; sum++) {
vector<int> &cells = left_diagonal[sum];
for (int r = 0, c = sum; r < H; r++, c--) {
if (0 > c or c >= W) continue;
cells.push_back(cell(r, c));
}
}
vector<vector<int>> right_diagonal(H + W);
for (int diff = 1 - W; diff < H; diff++) {
vector<int> &cells = right_diagonal[diff + W];
for (int r = 0, c = r - diff; r < H; r++, c++) {
if (0 > c or c >= W) continue;
cells.push_back(cell(r, c));
}
}
const int w = check(left_diagonal, K);
const int x = check(right_diagonal, K);
const int y = check(left_diagonal, K - 1);
const int z = check(right_diagonal, K - 1);
add_and({
add_and({w, x}),
add_not(add_and({y, z}))
});
}
Compilation message
vision.cpp: In function 'int check(const std::vector<std::vector<int> >&, int)':
vision.cpp:42:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for (int i = k; i < a.size(); i++) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
296 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
284 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
296 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
284 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
232 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
296 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
284 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
232 KB |
Output is correct |
28 |
Correct |
12 ms |
1108 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
2 ms |
340 KB |
Output is correct |
32 |
Correct |
2 ms |
432 KB |
Output is correct |
33 |
Correct |
2 ms |
428 KB |
Output is correct |
34 |
Correct |
9 ms |
1064 KB |
Output is correct |
35 |
Correct |
13 ms |
1492 KB |
Output is correct |
36 |
Correct |
10 ms |
1136 KB |
Output is correct |
37 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
296 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
284 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
232 KB |
Output is correct |
28 |
Correct |
12 ms |
1108 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
2 ms |
340 KB |
Output is correct |
32 |
Correct |
2 ms |
432 KB |
Output is correct |
33 |
Correct |
2 ms |
428 KB |
Output is correct |
34 |
Correct |
9 ms |
1064 KB |
Output is correct |
35 |
Correct |
13 ms |
1492 KB |
Output is correct |
36 |
Correct |
10 ms |
1136 KB |
Output is correct |
37 |
Correct |
2 ms |
340 KB |
Output is correct |
38 |
Incorrect |
4 ms |
4396 KB |
WA in grader: Too many inputs |
39 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
560 KB |
Output is correct |
2 |
Correct |
7 ms |
980 KB |
Output is correct |
3 |
Correct |
8 ms |
948 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
9 ms |
936 KB |
Output is correct |
7 |
Correct |
7 ms |
852 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
468 KB |
Output is correct |
10 |
Correct |
6 ms |
852 KB |
Output is correct |
11 |
Correct |
8 ms |
936 KB |
Output is correct |
12 |
Correct |
7 ms |
980 KB |
Output is correct |
13 |
Correct |
6 ms |
724 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
560 KB |
Output is correct |
16 |
Correct |
7 ms |
852 KB |
Output is correct |
17 |
Correct |
8 ms |
996 KB |
Output is correct |
18 |
Correct |
8 ms |
980 KB |
Output is correct |
19 |
Correct |
8 ms |
784 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
296 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
7 ms |
680 KB |
Output is correct |
4 |
Correct |
60 ms |
6032 KB |
Output is correct |
5 |
Correct |
79 ms |
8308 KB |
Output is correct |
6 |
Correct |
62 ms |
6548 KB |
Output is correct |
7 |
Correct |
5 ms |
812 KB |
Output is correct |
8 |
Correct |
8 ms |
1108 KB |
Output is correct |
9 |
Incorrect |
3 ms |
4308 KB |
WA in grader: Too many inputs |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
5664 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
4 ms |
684 KB |
Output is correct |
4 |
Correct |
7 ms |
1108 KB |
Output is correct |
5 |
Correct |
2 ms |
556 KB |
Output is correct |
6 |
Correct |
3 ms |
468 KB |
Output is correct |
7 |
Correct |
23 ms |
2948 KB |
Output is correct |
8 |
Correct |
28 ms |
2980 KB |
Output is correct |
9 |
Correct |
60 ms |
5740 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
296 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
284 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
232 KB |
Output is correct |
28 |
Correct |
12 ms |
1108 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
2 ms |
340 KB |
Output is correct |
32 |
Correct |
2 ms |
432 KB |
Output is correct |
33 |
Correct |
2 ms |
428 KB |
Output is correct |
34 |
Correct |
9 ms |
1064 KB |
Output is correct |
35 |
Correct |
13 ms |
1492 KB |
Output is correct |
36 |
Correct |
10 ms |
1136 KB |
Output is correct |
37 |
Correct |
2 ms |
340 KB |
Output is correct |
38 |
Incorrect |
4 ms |
4396 KB |
WA in grader: Too many inputs |
39 |
Halted |
0 ms |
0 KB |
- |