#include "vision.h"
#include<bits/stdc++.h>
using namespace std;
bool limites(int x, int y, int h, int w){
return x>=0&&x<h&&y>=0&&y<w;
}
void construct_network(int H, int W, int K) {
map<pair<int,int>,int>numero;
int pos=1;
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
numero[{i,j}]=pos;
pos++;
}
}
vector<int>dx,dy;
for(int restar=0;restar<=K;restar++){
int c_x=restar;
int c_y=K-restar;
dx.push_back(c_x);
dy.push_back(c_y);
dx.push_back(-c_x);
dy.push_back(c_y);
dx.push_back(c_x);
dy.push_back(-c_y);
dx.push_back(-c_x);
dy.push_back(-c_y);
}
map<pair<pair<int,int>,pair<int,int>>,bool>marked;
int cnt=1;
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
for(int itr=0;itr<dx.size();itr++){
int x=i+dx[itr];
int y=j+dy[itr];
if(limites(x,y,H,W)){
if(!marked[{{i,j},{x,y}}]){
and_and({numero[{i,j}],numero[{x,y}]});
cnt++;
}
}
}
}
}
vector<int>instruct;
for(int i=H*W+1;i<=(H*W+cnt);i++){
instruct.push_back(i);
}
and_or(instruct);
return;
}
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:33:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int itr=0;itr<dx.size();itr++){
| ~~~^~~~~~~~~~
vision.cpp:38:7: error: 'and_and' was not declared in this scope; did you mean 'add_and'?
38 | and_and({numero[{i,j}],numero[{x,y}]});
| ^~~~~~~
| add_and
vision.cpp:49:2: error: 'and_or' was not declared in this scope; did you mean 'add_or'?
49 | and_or(instruct);
| ^~~~~~
| add_or