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;
int n, m, k;
vector<int> Aor, Axor, Bor, Bxor;
int get(int i, int j) { return m * i + j; }
int add_and(int a, int b) { return add_and({a, b}); }
int add_and_not(int a, int b) { return add_and(a, add_not(b)); }
void gen_diag(vector<int> &ovec, vector<int> &xvec, bool flip) {
for(int sum = 0; sum < n + m - 1; sum++) {
vector<int> now;
for(int i = 0; i < n; i++) {
int j = flip ? m - sum + i - 1 : sum - i;
if(j < 0 || j > m - 1) continue;
now.emplace_back(get(i, j));
//printf("(%d %d) ", i, j);
}
//printf("\n");
ovec.emplace_back(add_or(now));
xvec.emplace_back(add_xor(now));
}
}
int count(vector<int> &ovec, vector<int> &xvec, int dist) {
vector<int> lo, lx, ret;
++dist;
for(int i = 0; i < (int)ovec.size(); i++) {
lo.emplace_back(ovec[i]), lx.emplace_back(xvec[i]);
if((int)lo.size() > dist)
lo.erase(lo.begin()), lx.erase(lx.begin());
if((int)lo.size() == dist) {
ret.emplace_back(add_and_not(add_or(lo), add_xor(lx)));
//printf("gate = %d\n", ret.back());
}
}
return add_or(ret);
}
void construct_network(int _n, int _m, int _k) {
n = _n, m = _m, k = _k;
gen_diag(Aor, Axor, false);
gen_diag(Bor, Bxor, true);
add_and_not(add_and(count(Aor, Axor, k), count(Bor, Bxor, k)),
add_and(count(Aor, Axor, k - 1), count(Bor, Bxor, k - 1)));
}
# | 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... |