#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
/*
int h,w,k;
vector <int> t;
int current;
int calls=0;
void add_or(vector <int> v){
cout<<"Call No. "<<calls<<": requested ";
for (auto&i:v) cout<<i<<' ';
cout<<endl;
calls++;
int n=v.size();
if (n>10001){
cout<<"Too many instructions on call and_or\n";
exit(0);
}
for (int i=0; i<n; i++){
if (v[i]<0||v[i]>=current){
cout<<"Invalid index provided on call and_or: "<<i<<"th element requested for "<<v[i];
exit(0);
}
}
int res=0;
for (int i=0; i<n; i++){
if (t[v[i]]==1){
res=1;
break;
}
}
t.push_back(res);
current++;
}
*/
void construct_network(int H,int W,int K){
if (K==1){
int cnt=0;
for (int i=0; i<H; i++){
for (int j=0; j<W-1; j++){
add_and({i*W+j,i*W+j+1});
cnt++;
}
}
for (int j=0; j<W; j++){
for (int i=0; i<H-1; i++){
add_and({i*w+j,(i+1)*w+j});
cnt++;
}
}
vector <int> v;
for (int i=0; i<cnt; i++) v.push_back(H*W+i);
add_or(v);
return;
}
int cnt=0;
map <pair <int,int>,bool> p;
for (int i=0; i<H; i++){
for (int j=0; j<W; j++){
for (int xp=i,yp=j-K; xp!=i-K&&yp!=j; xp--,yp++){
if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
add_and({i*W+j,xp*W+yp});
cnt++;
p[{i*W+j,xp*W+yp}]=1;
}
}
for (int xp=i-K,yp=j; xp!=i&&yp!=j+K; xp++,yp++){
if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
add_and({i*W+j,xp*W+yp});
cnt++;
p[{i*W+j,xp*W+yp}]=1;
}
}
for (int xp=i,yp=j+K; xp!=i+K&&yp!=j; xp++,yp--){
if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
add_and({i*W+j,xp*W+yp});
cnt++;
p[{i*W+j,xp*W+yp}]=1;
}
}
for (int xp=i+K,yp=j; xp!=i&&yp!=j-K; xp--,yp--){
if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
add_and({i*W+j,xp*W+yp});
cnt++;
p[{i*W+j,xp*W+yp}]=1;
}
}
}
}
if (cnt==1) return;
//cnt results stored in [h*w,h*w+cnt)
vector <int> v;
int curpr=0,cnt1=0;
for (int i=0; i<cnt; i++){
v.push_back(H*W+i);
curpr++;
if (i==cnt-1){
add_or(v);
v.clear();
cnt1++;
curpr=0;
}
}
if (cnt1==1) return;
//cnt1 results stored in [h*w+cnt,h*w+cnt+cnt1)
v.clear();
for (int i=H*W+cnt; i<H*W+cnt+cnt1; i++){
v.push_back(i);
}
add_or(v);
return;
}
/*
int main(){
cin>>h>>w>>k;
for (int i=0; i<h*w; i++){
int v;
cin>>v;
t.push_back(v);
}
current=h*w;
construct_network(h,w,k);
for (auto&i:t) cout<<i<<' ';
cout<<endl;
}
*/
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:47:16: error: 'w' was not declared in this scope
47 | add_and({i*w+j,(i+1)*w+j});
| ^
vision.cpp:47:30: error: could not convert '{<expression error>, <expression error>}' from '<brace-enclosed initializer list>' to 'std::vector<int>'
47 | add_and({i*w+j,(i+1)*w+j});
| ^
| |
| <brace-enclosed initializer list>