#include "bits/stdc++.h"
#include "vision.h"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
int n,m;
inline int get_ind(int a,int b){
return a*m+b;
}
inline bool is_valid(int a,int b){
return a>=0 && a<n && b>=0 && b<m;
}
map<int,int> info1_l,info1_r,info2_l,info2_r;
void construct_network(int _n, int _m, int k){
n = _n , m = _m;
int p = 0;
while(p<n){
int c = p , d = 0;
vector<int> res;
while(is_valid(c,d)){
res.push_back(get_ind(c,d));
c--,d++;
}
info1_l[p] = add_or(res);
p++;
}
p = 1;
while(p<m){
int c = n - 1 , d = p;
vector<int> res;
while(is_valid(c,d)){
res.push_back(get_ind(c,d));
c--,d++;
}
info1_l[n-1+p] = add_or(res);
p++;
}
int p = 0;
while(p<n){
int c = p , d = 0;
vector<int> res;
while(is_valid(c,d)){
res.push_back(get_ind(c,d));
c--,d++;
}
info2_l[p] = add_and({info1_l[p],add_not(add_xor(res))});
p++;
}
int p = 1;
while(p<m){
int c = n - 1 , d = p;
vector<int> res;
while(is_valid(c,d)){
res.push_back(get_ind(c,d));
c--,d++;
}
info2_l[n-1+p] = add_and({info1_l[n-1+p],add_not(add_xor(res))});
p++;
}
p = n - 1;
while(p >= 0){
int c = p , d = 0;
vector<int> res;
while(is_valid(c,d)){
res.push_back(get_ind(c,d));
c++,d++;
}
info1_r[p] = add_or(res);
p--;
}
p = 1;
while(p<m){
int c = 0 , d = p;
vector<int> res;
while(is_valid(c,d)){
res.push_back(get_ind(c,d));
c++,d++;
}
info1_r[-p] = add_or(res);
p++;
}
p = n - 1;
while(p >= 0){
int c = p , d = 0;
vector<int> res;
while(is_valid(c,d)){
res.push_back(get_ind(c,d));
c++,d++;
}
info2_r[p] = add_and({info1_r[p],add_not(add_xor(res))});
p--;
}
p = 1;
while(p < m){
int c = 0 , d = p;
vector<int> res;
while(is_valid(c,d)){
res.push_back(get_ind(c,d));
c++,d++;
}
info2_r[-p] = add_and({info1_r[-p],add_not(add_xor(res))});
p++;
}
vector<int> l_diagonals,r_diagonals;
for(int i = 0; i <= n + m - 2; i++) l_diagonals.push_back(i);
for(int i = n - 1; i >= 1 - m; i--) r_diagonals.push_back(i);
vector<int> ok_l;
for(int x : l_diagonals) ok_l.push_back(info2_l[x]);
for(int i = k - 1; i < sz(l_diagonals) ; i++){
vector<int> res;
for(int j = i ; j > i - k; j--) res.push_back(info1_l[l_diagonals[j]]);
ok_l.push_back(add_and({add_or(res),add_not(add_xor(res))}));
}
vector<int> ok_r;
for(int x : r_diagonals) ok_r.push_back(info2_r[x]);
for(int i = k - 1; i < sz(r_diagonals) ; i++){
vector<int> res;
for(int j = i ; j > i - k; j--) res.push_back(info1_r[r_diagonals[j]]);
ok_r.push_back(add_and({add_or(res),add_not(add_xor(res))}));
}
int hm1 = add_and({add_or(ok_l),add_or(ok_r)});
ok_l.clear();
for(int x : l_diagonals) ok_l.push_back(info2_l[x]);
for(int i = k; i < sz(l_diagonals) ; i++){
vector<int> res;
for(int j = i ; j >= i - k; j--) res.push_back(info1_l[l_diagonals[j]]);
ok_l.push_back(add_and({add_or(res),add_not(add_xor(res))}));
}
ok_r.clear();
for(int x : r_diagonals) ok_r.push_back(info2_r[x]);
for(int i = k; i < sz(r_diagonals) ; i++){
vector<int> res;
for(int j = i ; j >= i - k; j--) res.push_back(info1_r[r_diagonals[j]]);
ok_r.push_back(add_and({add_or(res),add_not(add_xor(res))}));
}
int hm2 = add_and({add_or(ok_l),add_or(ok_r)});
add_and({add_not({hm1}),hm2});
}
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:47:7: error: redeclaration of 'int p'
47 | int p = 0;
| ^
vision.cpp:23:7: note: 'int p' previously declared here
23 | int p = 0;
| ^
vision.cpp:60:7: error: redeclaration of 'int p'
60 | int p = 1;
| ^
vision.cpp:23:7: note: 'int p' previously declared here
23 | int p = 0;
| ^