이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "vision.h"
template <class T> using Vec = std::vector<T>;
template <class... Args>
Vec<int> vec(Args&&... args) {
return Vec<int>{std::forward<Args>(args)...};
}
void construct_network(int H, int W, int K) {
const auto cell = [&](const int i, const int j) {
return i * W + j;
};
const auto inside = [&](const int i, const int j) {
return 0 <= i and i < H and 0 <= j and j < W;
};
if (std::max(H, W) <= 30 or std::min(H, W) == 1) {
Vec<int> check;
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
Vec<int> see;
int x = i, y = j + K;
while (y > j) {
if (inside(x, y)) {
see.push_back(cell(x, y));
}
x += 1;
y -= 1;
}
while (x > i) {
if (inside(x, y)) {
see.push_back(cell(x, y));
}
x -= 1;
y -= 1;
}
if (!see.empty()) {
const int exists = add_or(see);
check.push_back(add_and(vec(cell(i, j), exists)));
}
}
}
add_or(check);
} else if (K == 1) {
Vec<int> row(H), column(W);
for (int i = 0; i < H; ++i) {
Vec<int> ask(W);
for (int j = 0; j < W; ++j) {
ask[j] = cell(i, j);
}
row[i] = add_or(ask);
}
for (int j = 0; j < W; ++j) {
Vec<int> ask(H);
for (int i = 0; i < H; ++i) {
ask[i] = cell(i, j);
}
column[j] = add_or(ask);
}
Vec<int> row_adj(H - 1), column_adj(W - 1);
for (int i = 0; i < H - 1; ++i) {
row_adj[i] = add_and(vec(row[i], row[i + 1]));
}
for (int i = 0; i < W - 1; ++i) {
column_adj[i] = add_and(vec(column[i], column[i + 1]));
}
const int row_xor = add_xor(row);
const int column_xor = add_xor(column);
const int row_adj_or = add_or(row_adj);
const int column_adj_or = add_or(column_adj);
const int x = add_and(vec(row_xor, column_adj_or));
const int y = add_and(vec(column_xor, row_adj_or));
add_or(vec(x, y));
} else {
Vec<int> see;
int x = 0, y = 0 + K;
while (y > 0) {
if (inside(x, y)) {
see.push_back(cell(x, y));
}
x += 1;
y -= 1;
}
while (x > 0) {
if (inside(x, y)) {
see.push_back(cell(x, y));
}
x -= 1;
y -= 1;
}
const int exists = add_or(see);
add_and(vec(cell(0, 0), exists));
}
}
# | 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... |