이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "vision.h"
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
using namespace std;
template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
void construct_network(int H, int W, int K) {
if (K == 1) {
int idx = -1;
for (int i = 0; i < H; i++) {
vector<int> cur;
for (int j = 0; j < W; j++) {
cur.push_back(i*W+j);
}
if (idx == -1) idx = add_or(cur);
else idx = add_xor({idx, add_or(cur)});
}
for (int i = 0; i < W; i++) {
vector<int> cur;
for (int j = 0; j < H; j++) {
cur.push_back(j*W+i);
}
assert(~idx);
idx = add_xor({idx, add_or(cur)});
}
int idx2 = -1;
for (int i = 0; i < H-1; i++) {
vector<int> cur;
for (int j = 0; j < W; j++) {
cur.push_back(i*W+j);
cur.push_back((i+1)*W+j);
}
if (idx2 == -1) idx2 = add_or(cur);
else idx2 = add_or({idx2, add_or(cur)});
}
for (int i = 0; i < W-1; i++) {
vector<int> cur;
for (int j = 0; j < H; j++) {
cur.push_back(j*W+i);
cur.push_back(j*W+i+1);
}
if (idx2 == -1) idx2 = add_or(cur);
else idx2 = add_or({idx2, add_or(cur)});
}
assert(~idx);
assert(~idx2);
add_and({idx, idx2});
}
vector<int> res;
if ((H <= 30 && W <= 30) || min(H, W) == 1) {
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
vector<int> cur;
for (int k = 0; k < H; k++) {
for (int l = 0; l < W; l++) {
if (abs(k - i) + abs(j - l) == K) {
cur.emplace_back(k*W+l);
}
}
}
if (cur.size()) {
int idx = add_or(cur);
res.emplace_back(add_and({i*W+j, idx}));
}
}
}
}
else {
vector<int> cur;
for (int k = 0; k < H; k++) {
for (int l = 0; l < W; l++) {
if (k + l == K) {
cur.emplace_back(k*W+l);
}
}
}
if (cur.size()) {
int idx = add_or(cur);
res.emplace_back(add_and({0, idx}));
}
}
add_or(res);
}
# | 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... |