#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
void build(vector<int> u,vector<int> v, vector<int> a, vector<int> b);
void mbuild(vector<int> u,vector<int> v, vector<int> a, vector<int> b){
int m = u.size();
for(int i = 0; i < m; i++){
cout << u[i] << " " << v[i] << " " << a[i] << " " << b[i] << "\n";
}
}
int construct_roads(vector<int> sus, vector<int> amongus){
set<array<int,3>> a; set<array<int,2>> used;
int n = sus.size();
vector<int> par(n),sz(n,1); int cnt = n;
for(int i = 0; i < n; i++) a.insert({sus[i],amongus[i],i}),par[i] = i;
auto has = [&](int x, int y){
auto itr = a.lower_bound({x,y,-1});
if(itr == a.end()) return -1;
return (*itr)[2];
};
auto find = [&](int x){
while(x != par[x]){
par[x] = par[par[x]];
x = par[x];
}
return x;
};
auto join = [&](int x, int y){
x = find(x); y = find(y);
if(x == y) return false;
if(sz[x] > sz[y]) swap(x,y);
sz[y] += sz[x];
cnt--;
par[x] = y;
return true;
};
vector<int> u,v,ba,bb;
auto add_sol = [&](int i, int j, int x, int y){ // connect fountain i and j with (x,y) bench
u.emplace_back(i); v.emplace_back(j);
used.insert({x,y});
ba.emplace_back(x); bb.emplace_back(y);
};
for(auto[x,y,i] : a){
int p;
if((p = has(x+2,y)) != -1){
if(find(i) != find(p)){
if((x+y) % 4 == 0){
join(i,p);
add_sol(i,p,x+1,y+1);
} else if(used.find({x+1,y-1}) == used.end()){
join(i,p);
add_sol(i,p,x+1,y-1);
}
}
}
if((p = has(x,y+2)) != -1){
if(find(i) != find(p)){
if((x+y) % 4 != 0){
join(i,p);
add_sol(i,p,x+1,y+1);
} else if(used.find({x-1,y+1}) == used.end()){
join(i,p);
add_sol(i,p,x-1,y+1);
}
}
}
}
if(cnt != 1) return 0;
build(u,v,ba,bb);
//mbuild(u,v,ba,bb);
return 1;
}
int main(){
cin.tie(0)->sync_with_stdio(0);
//cout << construct_roads({4,4,6,4,2},{4,7,4,2,4}) << "\n";
return 0;
}
Compilation message
/usr/bin/ld: /tmp/ccwWTpTL.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccCG1CGL.o:parks.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status