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;
void construct_network(int h, int w, int K) {
vector<int> ops;
// [hw, hw+h)
for (int i=0; i<h; ++i) {
ops.clear();
for (int j=0; j<w; ++j) ops.push_back(i*w+j);
add_xor(ops);
}
// [hw+h, hw+h+w)
for (int i=0; i<w; ++i) {
ops.clear();
for (int j=0; j<h; ++j) ops.push_back(j*w+i);
add_xor(ops);
}
// [hw+h+w, hw+2(h+w))
add_or({h*w});
for (int i=1; i<h; ++i) add_xor({ h*w+h+w+i-1, h*w+i });
add_or({h*w+h});
for (int i=1; i<w; ++i) add_xor({ h*w+h+w+h+i-1, h*w+h+i });
// [0, i] sum is at [hw+2(h+w)+8i, +8)
add_or({h*w+h+w});
for (int i=1; i<16; ++i) add_xor({ 0, 0 }); // make offset for C_in
for (int i=1; i<h+w; ++i) {
int prv_s = h*w + 2*(h+w) + 16*(i-1);
int curr_s = prv_s + 16;
int b = h*w+h+w+i;
add_xor({ prv_s, b });
add_and({ prv_s, b });
for (int j=1; j<8; ++j) {
add_xor({ prv_s + 2*j, curr_s + 2*j-1 });
add_and({ prv_s + 2*j, curr_s + 2*j-1 });
}
}
int last_s = h*w + 18*(h+w);
for (int i=0; i<8; ++i) {
if (K & (1 << i)) {
add_or({ last_s - 16 + 2*i });
} else {
add_not(last_s - 16 + 2*i);
}
}
ops.clear();
for (int i=0; i<8; ++i) ops.push_back(last_s + i);
add_and(ops);
}
# | 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... |