#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,N) for(long long i = 0; (i) < (N); (i)++)
#define FORS(i,v,N) for(long long i = v; (i) < (N); (i)++)
#define FORI(i,v,N,inc) for(long long i = v; (i) < (N); (i)+=(inc))
#define NL '\n'
#define EL std::cout << NL
#define PRINTV(v) for(auto a:(v)) {std::cout << a << " ";};EL
#define PRINTVV(v) for(auto a:(v)) {PRINTV(a);}
typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VLL;
typedef pair<ll,ll> PL;
typedef vector<PL> VPL;
typedef vector<VPL> VVPL;
void construct_network(int H, int W, int K) {
std::vector<int> Ns;
int z,o;
if (H*W > 3) {
z = add_and({0,1,2});
o = add_not(z);
} else {
o = add_and({0,1});
z = add_not(o);
}
vector<vector<int>> xinter0(8);
vector<vector<int>> xinter1(8);
vector<vector<int>> yinter0(8);
vector<vector<int>> yinter1(8);
int pow = 1;
FOR(n,8) {
FOR(i,H*W) {
if (((i%W)/pow) % 2) {
xinter1[n].push_back(i);
} else {
xinter0[n].push_back(i);
}
if (((i/W)/pow) % 2) {
yinter1[n].push_back(i);
} else {
yinter0[n].push_back(i);
}
}
pow *= 2;
}
vector<vector<vector<int>>> xinter11(8,vector<vector<int>>(8));
vector<vector<vector<int>>> yinter11(8,vector<vector<int>>(8));
vector<vector<vector<int>>> xinter10(8,vector<vector<int>>(8));
vector<vector<vector<int>>> yinter10(8,vector<vector<int>>(8));
pow = 1;
FOR(m,8) {
FOR(n,8) {
for(int i : xinter1[n]) {
if (((i%W)/pow) % 2) {
xinter11[m][n].push_back(i);
}
}
for(int i : xinter0[n]) {
if (((i%W)/pow) % 2) {
xinter10[m][n].push_back(i);
}
}
}
pow *= 2;
}
pow = 1;
FOR(m,8) {
FOR(n,8) {
for(int i : yinter1[n]) {
if (((i/W)/pow) % 2) {
yinter11[m][n].push_back(i);
}
}
for(int i : yinter0[n]) {
if (((i/W)/pow) % 2) {
yinter10[m][n].push_back(i);
}
}
}
pow *= 2;
}
FOR(m,8) {
FOR(n,8) {
if (xinter11[m][n].size() == 0) {
xinter11[m][n] = {z};
}
if (yinter11[m][n].size() == 0) {
yinter11[m][n] = {z};
}
if (xinter10[m][n].size() == 0) {
xinter10[m][n] = {z};
}
if (yinter10[m][n].size() == 0) {
yinter10[m][n] = {z};
}
}
}
//PRINTV(xinter0[6]); EL;
//PRINTVV(xinter1); EL;
//PRINTVV(yinter0); EL;
//PRINTVV(yinter1); EL;
vector<int> x1(8);
vector<int> x2(8);
vector<int> y1(8);
vector<int> y2(8);
vector<int> xbreakbits;
vector<int> ybreakbits;
for(int i = 7; i >= 0; i--) {
vector<int> i0 = xinter0[i];
vector<int> i1 = xinter1[i];
if (i0.size() == 0) i0 = {z};
if (i1.size() == 0) i1 = {z};
int is_diff = add_and({add_xor(i0),add_xor(i1)});
int or_bit = add_or(i1);
if (i == 7) {
xbreakbits.push_back(add_or({is_diff}));
} else {
xbreakbits.push_back(add_and({add_not(add_or(xbreakbits)),is_diff}));
}
vector<int> disc_listA;
vector<int> disc_listB;
for(int j = 7; j >= i; j--) {
disc_listA.push_back(add_and({add_or(xinter10[i][j]),xbreakbits[7-j]}));
disc_listB.push_back(add_and({add_or(xinter11[i][j]),xbreakbits[7-j]}));
}
int discA = add_or(disc_listA);
int discB = add_or(disc_listB);
//vector<int> db = {is_diff,discA,discB};
//print_vals(db);
x1[i] = add_or({add_and({or_bit,add_not(is_diff)}),add_and({is_diff,discA})});
x2[i] = add_or({add_and({or_bit,add_not(is_diff)}),add_and({is_diff,discB})});
}
for(int i = 7; i >= 0; i--) {
vector<int> i0 = yinter0[i];
vector<int> i1 = yinter1[i];
if (i0.size() == 0) i0 = {z};
if (i1.size() == 0) i1 = {z};
int is_diff = add_and({add_xor(i0),add_xor(i1)});
int or_bit = add_or(i1);
if (i == 7) {
ybreakbits.push_back(add_or({is_diff}));
} else {
ybreakbits.push_back(add_and({add_not(add_or(ybreakbits)),is_diff}));
}
vector<int> disc_listA;
vector<int> disc_listB;
for(int j = 7; j >= i; j--) {
disc_listA.push_back(add_and({add_or(yinter10[i][j]),ybreakbits[7-j]}));
disc_listB.push_back(add_and({add_or(yinter11[i][j]),ybreakbits[7-j]}));
}
int discA = add_or(disc_listA);
int discB = add_or(disc_listB);
//vector<int> db = {is_diff,discA,discB};
//print_vals(db);
y1[i] = add_or({add_and({or_bit,add_not(is_diff)}),add_and({is_diff,discA})});
y2[i] = add_or({add_and({or_bit,add_not(is_diff)}),add_and({is_diff,discB})});
}
print_vals(x1);
print_vals(x2);
print_vals(y1);
print_vals(y2);
vector<int> rx1(9);
vector<int> ry1(9);
vector<int> dx(9);
vector<int> dy(9);
FOR(i,8) {
rx1[i] = add_not(x1[i]);
ry1[i] = add_not(y1[i]);
}
int c1 = z;
FOR(i,8) {
rx1[i] = add_xor({c1,o,rx1[i]});
c1 = add_or({c1,rx1[i]});
}
c1 = z;
FOR(i,8) {
ry1[i] = add_xor({c1,o,ry1[i]});
c1 = add_or({c1,ry1[i]});
}
rx1[8] = ry1[8] = o;
int c = z;
FOR(i,8) {
dx[i] = add_xor({rx1[i],x2[i],c});
c = add_or({add_and({rx1[i],x2[i]}),add_and({rx1[i],c}),add_and({c,x2[i]})});
}
dx[8] = add_xor({c,o});
c = z;
FOR(i,8) {
dy[i] = add_xor({ry1[i],y2[i],c});
c = add_or({add_and({ry1[i],y2[i]}),add_and({ry1[i],c}),add_and({c,y2[i]})});
}
dy[8] = add_xor({c,o});
print_vals(rx1);
print_vals(ry1);
print_vals(dx);
print_vals(dy);
c = z;
vector<int> dist(9);
FOR(i,9) {
dist[i] = add_xor({dx[i],dy[i],c});
c = add_or({add_and({dx[i],dy[i]}),add_and({dx[i],c}),add_and({c,dy[i]})});
}
print_vals(dist);
vector<int> kdist;
vector<int> pos,pos2;
while(K) {
kdist.push_back(K%2);
K /= 2;
}
//PRINTV(kdist);
FOR(i,8) {
if (i < (int)kdist.size() && kdist[i]) {
pos.push_back(dist[i]);
} else {
pos2.push_back(dist[i]);
}
}
if (pos.size() == 0) {
pos = {z};
} else if (pos2.size() == 0) {
pos2 = {z};
}
print_vals(pos);
print_vals(pos2);
add_and({add_and(pos),add_not(add_or(pos2))});
//print_vals(xbreakbits);
return;
}
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:165:2: error: 'print_vals' was not declared in this scope
165 | print_vals(x1);
| ^~~~~~~~~~