#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
void construct_network(int H,int W,int K){
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_or({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_or({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_or({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_or({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||curpr==10000){
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);
}
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:44:15: error: 'h' was not declared in this scope
44 | v.push_back(h*w+i);
| ^
vision.cpp:44:17: error: 'w' was not declared in this scope
44 | v.push_back(h*w+i);
| ^
vision.cpp:56:13: error: 'h' was not declared in this scope
56 | for (int i=h*w+cnt; i<h*w+cnt+cnt1; i++){
| ^
vision.cpp:56:15: error: 'w' was not declared in this scope
56 | for (int i=h*w+cnt; i<h*w+cnt+cnt1; i++){
| ^