This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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++) {
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |