#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;
struct foo {
int black1;
int black2;
};
int check(const vector<foo> &a, const int k) {
auto add = [&](deque<int> &d, const int i) {
d.push_back(i);
};
auto rem = [&](deque<int> &d, const int i) {
assert(d.front() == i);
d.pop_front();
};
auto get_vec = [&](deque<int> &d) -> vector<int> {
return {d.begin(), d.end()};
};
deque<int> or_d;
deque<int> xor_d;
for (int i = 0; i < k; i++) {
add(or_d, a[i].black1);
add(xor_d, a[i].black2);
}
vector<int> consider;
for (int i = k; i < a.size(); i++) {
add(or_d, a[i].black1);
add(xor_d, a[i].black2);
const int x = add_or(get_vec(or_d));
const int y = add_xor(get_vec(or_d));
const int z = add_xor(get_vec(xor_d));
consider.push_back(add_xor({x, y, z}));
rem(or_d, a[i - k].black1);
rem(xor_d, a[i - k].black2);
}
for (const int x : consider) {
cout << x << ' ';
}
cout << '\n';
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<foo> left_diagonal(H + W - 1);
for (int sum = 0; sum < H + W - 1; sum++) {
vector<int> cells;
for (int r = 0, c = sum; r < H; r++, c--) {
if (0 > c or c >= W) continue;
cells.push_back(cell(r, c));
}
left_diagonal[sum].black1 = add_or(cells);
left_diagonal[sum].black2 = add_xor({
left_diagonal[sum].black1,
add_xor(cells)
});
}
vector<foo> right_diagonal(H + W - 1);
for (int diff = 1 - W; diff < H; diff++) {
vector<int> cells;
for (int r = 0, c = r - diff; r < H; r++, c++) {
if (0 > c or c >= W) continue;
cells.push_back(cell(r, c));
}
right_diagonal[diff + W - 1].black1 = add_or(cells);
right_diagonal[diff + W - 1].black2 = add_xor({
right_diagonal[diff + W - 1].black1,
add_xor(cells)
});
}
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<foo>&, int)':
vision.cpp:45:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<foo>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for (int i = k; i < a.size(); i++) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
688 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
2448 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |