# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
493424 | 2021-12-11T09:36:57 Z | vendx_greyback | Swapping Cities (APIO20_swap) | C++14 | 0 ms | 0 KB |
#include "swap.h" #include <bits/stdc++.h> using namespace std; const int mxn = 1e5; int par[mxn], mx = 0; bool isLine = true; int get(int u){ if(u == par[u]) return u; return par[u] = get(par[u]); } void join(int u, int v){ u = get(u); v = get(v); par[u] = v; } void init(int n, int m, int u[], int v[], int w[]){ for(int i = 0; i < n; i++) par[i] = i; for(int i = 0; i < m; i++){ if(get(u[i]) == get(v[i])) isLine = false; else join(u[i], v[i]); mx = max(mx, w[i]); } } int getMinimumFuelCapacity(int x, int y){ return (isLine? -1: mx); }