#include <bits/stdc++.h>
//#include "vision.h"
using namespace std;
vector<pair<int, int> > pss = {{-1, 1}, {-1, -1}, {1, 1}, {1, -1}};
vector<pair<int, int> > dists(int e, int s, int k, int n, int m){
int pe = 0, ps = 0;
vector<pair<int, int> > ret;
vector<pair<int, int> > ans;
for(auto x : pss){
for(int i = 0; i <= k; i++){
pe = e + x.first * i;
ps = s + x.second * (k-i);
if(pe < 0 || pe >= n || ps < 0 || ps >= m) continue;
ret.push_back({pe, ps});
}
}
if(ret.size() == 0) return {};
sort(ret.begin(), ret.end());
ans.push_back(ret[0]);
for(int i = 1; i < (int) ret.size(); i++) if(ret[i] != ret[i-1]) ans.push_back(ret[i]);
return ans;
}
void construct_network(int n, int m, int k) {
if(k == 1){
int viso = 0;
for(int i = 0; i < n; i++){
vector<int> hsh;
for(int j = 0; j < m; j++){
hsh.push_back(i * m + j);
}
add_xor(hsh);
add_or(hsh);
viso += 2;
}
for(int i = 0; i < m; i++){
vector<int> hsh;
for(int j = 0; j < n; j++){
hsh.push_back(j * m + i);
}
add_xor(hsh);
add_or(hsh);
viso += 2;
}
int L = viso; int R = viso-1;
for(int i = 0; i < n + m; i++){
add_xor({2 * i, 2 * i + 1});
R++;
}
vector<int> last;
for(int i = L; i <= R; i++) last.push_back(i);
add_or(last);
return ;
}
int viso = 0; int prm = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
//cout << i << ", " << j << endl;
auto ms = dists(i, j, k, n, m);
if(ms.size() == 0) continue;
vector<int> hsh; for(auto x : ms) hsh.push_back(x.first * m + x.second);
add_or(hsh);
//cout << "nuo [" << i << "; " << j << "] nutole per " << k << ": "; for(auto x : ms) cout << "{" << x.first << ", " << x.second << "}, ";
//cout << endl;
viso++;
prm++;
}
}
if(prm == 0){
vector<int> ret;
for(int i = 0; i < n*m; i++) ret.push_back(i);
add_and(ret);
return;
}
int curInd = n * m;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
auto ms = dists(i, j, k, n, m);
if(ms.size() == 0) continue;
vector<int> hsh = {curInd, i * m + j};
add_and(hsh);
curInd++;
viso++;
}
}
int endd = viso;
vector<int> hsh;
for(int i = n * m + prm; i < n*m+endd; i++){
hsh.push_back(i);
}
add_or(hsh);
}
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:33:4: error: 'add_xor' was not declared in this scope
33 | add_xor(hsh);
| ^~~~~~~
vision.cpp:34:4: error: 'add_or' was not declared in this scope
34 | add_or(hsh);
| ^~~~~~
vision.cpp:42:4: error: 'add_xor' was not declared in this scope
42 | add_xor(hsh);
| ^~~~~~~
vision.cpp:43:4: error: 'add_or' was not declared in this scope
43 | add_or(hsh);
| ^~~~~~
vision.cpp:49:4: error: 'add_xor' was not declared in this scope
49 | add_xor({2 * i, 2 * i + 1});
| ^~~~~~~
vision.cpp:54:3: error: 'add_or' was not declared in this scope
54 | add_or(last);
| ^~~~~~
vision.cpp:66:4: error: 'add_or' was not declared in this scope
66 | add_or(hsh);
| ^~~~~~
vision.cpp:76:3: error: 'add_and' was not declared in this scope
76 | add_and(ret);
| ^~~~~~~
vision.cpp:86:4: error: 'add_and' was not declared in this scope
86 | add_and(hsh);
| ^~~~~~~
vision.cpp:96:2: error: 'add_or' was not declared in this scope
96 | add_or(hsh);
| ^~~~~~