#include "grader.cpp"
#include "vision.h"
#include <bits/stdc++.h>
#define pb(a) push_back(a)
using namespace std;
const int N = 1e7+5;
int d, h, w, used[N], cnt=0;
void fun(int xx,int yy){
vector<int> v;
for(int i=0;i<=d;i++){
int x = xx-i, y = yy-(d-i);
if(x>=0 && x<h &&y>=0 &&y<w){
v.pb(x*w+y);
}
}
for(int i=0;i<d;i++){
int x = xx-i, y = yy+(d-i);
if(x>=0 && x<h &&y>=0 &&y<w){
v.pb(x*w+y);
}
}
for(int i=1;i<=d;i++){
int x = xx+i, y = yy-(d-i);
if(x>=0 && x<h &&y>=0 &&y<w){
v.pb(x*w+y);
}
}
for(int i=1;i<d;i++){
int x = xx+i, y = yy+(d-i);
if(x>=0 && x<h &&y>=0 &&y<w){
v.pb(x*w+y);
}
}
if(v.size()){
add_or(v);
used[cnt]=xx*w+yy;
cnt++;
}
}
void construct_network(int H, int W, int k) {
d=k, h=H, w=W;
if(min(h,w) == 1){
h=max(h,w);
int l=0;
for(int i=0; i+k<h; i++){
add_and({i,i+k});
l++;
}
vector<int>v;
for(int i=0;i<l;i++){
v.pb(i+h);
}
add_or(v);
return;
}
else if(max(h,w) <= 30){
for(int i=0;i<h;i++)
for(int j=0;j<w;j++) fun(i,j);
int last = h*w;
for(int i=0; i<cnt; i++){
int cur = used[i], cur1 = i+last;
vector<int> v = {cur, cur1};
add_and(v);
}
vector<int>v;
for(int j=0; j<cnt; j++){
int i=last+cnt+j;
v.pb(i);
}
add_or(v);
return;
}
else if(k==1){
for(int i=0;i<h;i++){
vector<int>v;
for(int j=0;j<w;j++){
v.pb(i*w+j);
}
add_or(v);
}
for(int i=0;i<w;i++){
vector<int>v;
for(int j=0;j<h;j++){
v.pb(j*w+i);
}
add_or(v);
}
int last = h*w;
vector<int> v;
for(int i=0;i<h;i++){
int cur=last+i;
v.pb(cur);
}
add_xor(v);
v.clear();
for(int i=h;i<h+w;i++){
int cur=last+i;
v.pb(cur);
}
add_xor(v);
int ht = last+h+w, wt = ht+1;
for(int i=last;i<last+h-1;i++){
vector<int> tmp;
tmp = {wt, i, i+1};
add_and(tmp);
}
for(int i=last+h-1;i<last+h+w-2;i++){
vector<int> tmp;
tmp = {ht, i, i+1};
add_and(tmp);
}
v.clear();
for(int i=wt+1;i<wt+h+w-1;i++){
v.pb(i+last);
}
add_or(v);
}
else{
fun(0,0);
int last = h*w;
for(int i=0; i<cnt; i++){
int cur = used[i], cur1 = i+last;
vector<int> v = {cur, cur1};
add_and(v);
}
vector<int>v;
for(int j=0; j<cnt; j++){
int i = last + cnt + j;
v.pb(i);
}
add_or(v);
return;
}
}
Compilation message
/tmp/ccenoXzp.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccUT8ae1.o:vision.cpp:(.text.startup+0x0): first defined here
/tmp/ccenoXzp.o: In function `add_not(int)':
grader.cpp:(.text+0x260): multiple definition of `add_not(int)'
/tmp/ccUT8ae1.o:vision.cpp:(.text+0x770): first defined here
/tmp/ccenoXzp.o: In function `add_xor(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x430): multiple definition of `add_xor(std::vector<int, std::allocator<int> >)'
/tmp/ccUT8ae1.o:vision.cpp:(.text+0x5c0): first defined here
/tmp/ccenoXzp.o: In function `add_and(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x5e0): multiple definition of `add_and(std::vector<int, std::allocator<int> >)'
/tmp/ccUT8ae1.o:vision.cpp:(.text+0x260): first defined here
/tmp/ccenoXzp.o: In function `add_or(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x790): multiple definition of `add_or(std::vector<int, std::allocator<int> >)'
/tmp/ccUT8ae1.o:vision.cpp:(.text+0x410): first defined here
collect2: error: ld returned 1 exit status