Submission #979545

#TimeUsernameProblemLanguageResultExecution timeMemory
979545vjudge1Swapping Cities (APIO20_swap)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N =3e5 + 9 , mod = 1e9 + 7; ll p[N][3] , sz[N] ; vector<pair<ll,ll>>vv; int get(int x , vector<pair<ll,ll>>&vv ){ if(vv.size()) vv.pb({x , p[x][1] }); return (p[x][0] == x ? x : get(p[x][0] , vv)); } void join(int x , int y , ll k){ x = get(x , vv) , y = get(y , vv); if(x != y){ if(sz[x] < sz[y]) swap(x , y); p[y][0] = x; p[y][1] = k; p[x][2] = min(p[y][2] , p[x][2]); sz[x] += sz[y]; }else { p[y][2] = min(p[y][2] , k); } } int getMinimumFuelCapacity(int l, int r) { l++; r++; vector<pair<ll,ll>>v1 = {{0 , 0}}, v2= {{-1 , 0}}; get(l , v1); get(r , v2); ll x = v1.size() - 1, y = v2.size() - 1; ll mx = 0 , mn = 1e18; while(1){ mn = min({mn , max(v1[x].se , p[v1[x].fi][2] )}); if(v1[x].fi != v2[y].fi){ mx = max({mx , v1[x].se , v2[y].se }); break; } x-- , y--; } mx = max(mx , mn); while(1){ if(v1[x].fi != v2[y].fi){ mx = max({mx , v1[x].se , v2[y].se }); break; } x-- , y--; } if(mx == 1e18) mx = -1; return mx; return mx; } void init() { ll n , m; cin>>n>>m; vector<pair<ll,pair<ll,ll>>>vc; for(int i = 0; i <= n; i++) p[i][0] = i , p[i][1] = 0, p[i][2] = 1e18 , sz[i] = 1; for(int i = 0; i < m; i++){ ll u , c , v; cin>>u>>v>>c; vc.pb({c , {v + 1, u + 1}}); } sort(all(vc)); for(auto to : vc){ join(to.se.fi , to.se.se , to.fi); } ll q; cin>>q; while(q--){ ll x , y; cin>>x>>y; cout<<getMinimumFuelCapacity(x , y)<<"\n"; } } int main(){ init(); }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccbHIw0y.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccHHuTBy.o:swap.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccbHIw0y.o: in function `main':
grader.cpp:(.text.startup+0x1c3): undefined reference to `init(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status