이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#ifndef WEEE
#include "vision.h"
#else
vector<int> qvr;
int add_not(int a) {
qvr.push_back(qvr[a] ^ 1);
return ((int)qvr.size() - 1);
}
int add_or (vector<int> a) {
int dr = 0;
for(int i : a) dr |= qvr[i];
qvr.push_back(dr);
return ((int)qvr.size() - 1);
}
int add_and(vector<int> a) {
int dr = 1;
for(int i : a) dr &= qvr[i];
qvr.push_back(dr);
return ((int)qvr.size() - 1);
}
int add_xor(vector<int> a) {
int dr = 0;
for(int i : a) dr ^= qvr[i];
qvr.push_back(dr);
return ((int)qvr.size() - 1);
}
#endif
int __w;
inline int I(int i, int j) {
return i * __w + j;
}
void add(int &x, int y) {
// nx = x + 17
int nx = add_xor({x, y});
add_and({x, y});
for(int i = 2; i < 17; i += 2) {
add_xor({nx + i - 1, x + i});
if(i ^ 16) add_and({nx + i - 1, x + i});
}
x = nx;
}
void construct_network(int h, int w, int k) {
k += 2;
__w = w;
///
for(int i = 0; i < h; ++i) {
vector<int> tv;
for(int j = 0; j < w; ++j) {
tv.push_back(I(i, j));
}
add_or(tv);
}
//
for(int j = 0; j < w; ++j) {
vector<int> tv;
for(int i = 0; i < h; ++i) {
tv.push_back(I(i, j));
}
add_or(tv);
}
/////
add_or({h * w});
for(int i = 1; i < h; ++i) {
add_or({(h + 1) * (w + 1) - 1 + i - 1, h * w + i});
}
//
add_or({h * w + h - 1});
for(int i = h - 2; i >= 0; --i) {
add_or({(h + 1) * (w + 1) + h - 2 + (h - 1 - i), h * w + i});
}
/////
add_or({h * (w + 1)});
for(int i = 1; i < w; ++i) {
add_or({h * (w + 1) + i, (h + 1) * (w + 1) + h - 1 + i});
}
//
add_or({h * (w + 1) + w - 1});
for(int i = w - 2; i >= 0; --i) {
add_or({h * (w + 1) + i, (h + 1) * (w + 1) + 2 * h + w - 2 + (w - 1 - i)});
}
/////
for(int i = 0; i < h; ++i) {
add_and({(h + 1) * (w + 1) - 1 + i, (h + 1) * (w + 1) + 2 * h - 2 - i});
}
//
for(int i = 0; i < w; ++i) {
add_and({(h + 1) * (w + 1) + 2 * h - 1 + i, (h + 1) * (w + 1) + 2 * h + 2 * w - 2 - i});
}
/////
int tr = h * w + 4 * h + 4 * w, fl = tr + 1;
assert(add_or({(h + 1) * (w + 1) + h - 2}) == tr);
add_not(tr);
/////
int jl = (h + 1) * (w + 1) + 2 * h + 2 * w - 1, jr = jl + w + h - 1, x = fl + 1;
for(int i = 0; i < 17; ++i) add_or({fl});
for(int i = jl; i <= jr; ++i) add(x, i);
/////
int y = x + 17;
for(int i = 0; i < 9; ++i) {
add_or({(k & (1 << i) ? tr : fl)});
if(i ^ 8) add_or({fl});
}
int z = y + 17;
for(int i = 0; i < 9; ++i) {
add_xor({x + 2 * i, y + 2 * i});
}
for(int i = 0; i < 9; ++i) {
add_not(z + i);
}
z = z + 9;
{
vector<int> tv;
for(int i = 0; i < 9; ++i) {
tv.push_back(z + i);
}
add_and(tv);
}
}
#ifdef WEEE
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
qvr = {1, 0, 0, 1};
construct_network(2, 2, 2);
cout << qvr.size() << endl;
for(int i = 0; i < qvr.size(); ++i) {
cout << qvr[i] << " ";
}
cout << endl;
cout << "[.] " << *(--qvr.end()) << endl;
return 0;
}
#endif
# | 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... |