#include "swap.h"
#include "bits/stdc++.h"
#include "grader.cpp"
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define int long long
const int NN = 1e5+5;
int mx = 0, ok, res, d[NN], n, m;
vector<pair<int, int>> edges[NN];
vector<pair<int, int>> mm;
void init(int32_t N, int32_t M,
vector<int32_t> a, vector<int32_t> b, vector<int32_t> c) {
n = N, m = M;
for(int i=0;i<m;i++){
edges[a[i]].pb({b[i], c[i]});
edges[b[i]].pb({a[i], c[i]});
mx = max(mx, (int)c[i]);
}
if(n == m) res = mx;
else if(n - 1 == n){
res = -1;
ok = 1;
for(int i=0;i<m;i++) ok &= (min(a[i], b[i]) == 0);
if(ok){
for(int i=0;i<m;i++) d[max(a[i], b[i])] = c[i];
for(int i=1;i<n;i++) mm.pb({d[i], i});
mm.resize(3);
}
} sort(mm.begin(), mm.end());
}
/*
5 5
1 0 1
2 1 2
3 2 3
4 3 4
4 0 5
5
0 1
1 2
2 3
3 4
4 0
*/
int32_t getMinimumFuelCapacity(int32_t x, int32_t y) {
if(!ok) return res;
if(x > y) swap(x, y);
if(n == 2) return -1;
if(x == 0){
if(y == mm[0].ss || y == mm[1].ss || y == mm[2].ss) return max({mm[0].ff, mm[1].ff, mm[2].ff});
else return max({d[y], mm[0].ff, mm[1].ff});
} else {
if(n == 3) return -1;
if((mm[0].ss == y || mm[1].ss == y) && (mm[0].ss == x || mm[1].ss == x)) return max({d[x], d[y], mm[2].ff});
else if(x == mm[0].ss || y == mm[0].ss) return max({d[x], d[y], mm[1].ff});
else return max({d[x], d[y], mm[0].ff});
}
}
Compilation message
/usr/bin/ld: /tmp/ccSA7fTc.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccApy2Hd.o:swap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status