#include "vision.h"
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define int ll
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fv(a, c) for(int (a) = (1); (a) <= (c); (a)++)
#define fz(a, c) for(int (a) = (0); (a) < (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
#define pb push_back
#define in insert
#define ss second
#define ff first
#define vi vector <int>
#define fa(a, v) for(auto (a) : (v))
#define mnel(a) *min_element(all(a))
#define mxel(a) *max_element(all(a))
#define si set<int>
#define sov(a) sort(all((a)))
void construct_network(int h, int w, int K) {
vector<int> ss;
if(K == 1){
fp(i,0,h){
fp(j,0,w){
int x = i*w+j;
vi n;
fpp(k,-1,1){
int i1 = i + k, j1 = j + (abs(k) - K);
int i2 = i + k, j2 = j - (abs(k) - K);
if(i1 >= 0 && i1 < h && j1 >= 0 && j1 < w)
n.pb(i1*w + j1);
if(i2 >= 0 && i2 < h && j2 >= 0 && j2 < w)
n.pb(i2*w + j2);
}
ss.pb(add_and({x, add_or(n))});
}
}
}
if(max(h, w) > 10 && min(h, w) != 1){
int i = 0, j = 0;
int x = i*w + j;
fpp(k,-K, K){
int ii = i + k, jj = j + (abs(k) - K);
if(ii >= 0 && ii < h && jj >= 0 && jj < w)
ss.pb(add_and({x, ii*w +jj}));
ii = i + k, jj = j - (abs(k) - K);
if(ii >= 0 && ii < h && jj >= 0 && jj < w)
ss.pb(add_and({x, ii*w +jj}));
}
}
else{
fp(i,0,h){
fp(j,0,w){
int x = i*w + j;
fpp(k,-K, K){
int ii = i + k, jj = j + (abs(k) - K);
if(ii >= 0 && ii < h && jj >= 0 && jj < w)
ss.pb(add_and({x, ii*w +jj}));
ii = i + k, jj = j - (abs(k) - K);
if(ii >= 0 && ii < h && jj >= 0 && jj < w)
ss.pb(add_and({x, ii*w +jj}));
}
}
}
}
add_or(ss);
}
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:14:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
14 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
| ^
vision.cpp:33:3: note: in expansion of macro 'fp'
33 | fp(i,0,h){
| ^~
vision.cpp:14:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
14 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
| ^
vision.cpp:34:4: note: in expansion of macro 'fp'
34 | fp(j,0,w){
| ^~
vision.cpp:15:28: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
15 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
| ^
vision.cpp:37:5: note: in expansion of macro 'fpp'
37 | fpp(k,-1,1){
| ^~~
vision.cpp:45:32: error: expected '}' before ')' token
45 | ss.pb(add_and({x, add_or(n))});
| ~ ^
vision.cpp:45:33: error: expected ')' before '}' token
45 | ss.pb(add_and({x, add_or(n))});
| ~ ^
| )
vision.cpp:45:34: error: expected primary-expression before ')' token
45 | ss.pb(add_and({x, add_or(n))});
| ^
vision.cpp: At global scope:
vision.cpp:49:2: error: expected unqualified-id before 'if'
49 | if(max(h, w) > 10 && min(h, w) != 1){
| ^~
vision.cpp:61:2: error: expected unqualified-id before 'else'
61 | else{
| ^~~~
vision.cpp:76:8: error: expected constructor, destructor, or type conversion before '(' token
76 | add_or(ss);
| ^
vision.cpp:77:1: error: expected declaration before '}' token
77 | }
| ^