#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++){
int xp=i-K,yp=0,dir=0;
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:33:28: error: expected ')' before ';' token
33 | add_or({i*W+j,xp*W+yp};
| ~ ^
| )
vision.cpp:9:8: warning: unused variable 'xp' [-Wunused-variable]
9 | int xp=i-K,yp=0,dir=0;
| ^~
vision.cpp:9:15: warning: unused variable 'yp' [-Wunused-variable]
9 | int xp=i-K,yp=0,dir=0;
| ^~
vision.cpp:9:20: warning: unused variable 'dir' [-Wunused-variable]
9 | int xp=i-K,yp=0,dir=0;
| ^~~
vision.cpp:45:15: error: 'h' was not declared in this scope
45 | v.push_back(h*w+i);
| ^
vision.cpp:45:17: error: 'w' was not declared in this scope
45 | v.push_back(h*w+i);
| ^
vision.cpp:57:13: error: 'h' was not declared in this scope
57 | for (int i=h*w+cnt; i<h*w+cnt+cnt1; i++){
| ^
vision.cpp:57:15: error: 'w' was not declared in this scope
57 | for (int i=h*w+cnt; i<h*w+cnt+cnt1; i++){
| ^