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;
const int OP_NOT = 1;
const int OP_AND = 2;
const int OP_OR = 3;
const int OP_XOR = 4;
int gate(int op, vector<int> in) {
if (op == OP_NOT) {
return add_not(in[0]);
}
if (op == OP_AND) {
return add_and(in);
}
if (op == OP_OR) {
return add_or(in);
}
if (op == OP_XOR) {
return add_xor(in);
}
return -1;
}
void construct_network(int H, int W, int K) {
vector<int> bits;
for (int i = 0; i < H; i++) {
vector<int> in;
if (i > 0) {
in.push_back(bits.back());
}
for (int j = 0; j < W; j++) {
in.push_back(i * W + j);
}
bits.push_back(gate(OP_XOR, in));
}
for (int j = 0; j < W; j++) {
vector<int> in;
if (j > 0) {
in.push_back(bits.back());
}
for (int i = 0; i < H; i++) {
in.push_back(i * W + j);
}
bits.push_back(gate(OP_XOR, in));
}
vector<int> cur_sum(9, gate(OP_XOR, {0, 0}));
for (auto x: bits) {
int rem = x;
vector<int> nxt_sum(9);
for (int i = 0; i < 9; i++) {
nxt_sum[i] = gate(OP_XOR, {rem, cur_sum[i]});
if (i == 8) {
break;
}
rem = gate(OP_AND, {rem, cur_sum[i]});
}
cur_sum.swap(nxt_sum);
}
vector<int> check(9);
for (int i = 0; i < 9; i++) {
if ((K >> i) & 1) {
check[i] = cur_sum[i];
}
else {
check[i] = gate(OP_NOT, {cur_sum[i]});
}
}
gate(OP_AND, check);
}
# | 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... |