Submission #678596

#TimeUsernameProblemLanguageResultExecution timeMemory
678596Dan4LifeSwapping Cities (APIO20_swap)C++17
7 / 100
386 ms20772 KiB
#include "swap.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define SZ(a) (int)a.size() using ll = long long; const int maxn = (int)1e5+10; const int INF = (ll)1e9; vector<pair<int,int>> adj[maxn]; ll dis[maxn]; int tot = 0; int par[maxn]; bool vis[maxn]; int n, m; bool noCycle = false; multiset<int> S; int wei[maxn]; void init(int N, int M, vector<int> u, vector<int> v, vector<int> w) { n = N, m = M; for(int i = 0; i < M; i++){ wei[v[i]]=w[i]; adj[u[i]].pb({v[i],w[i]}); adj[v[i]].pb({u[i],w[i]}); tot=max(tot,w[i]); S.insert(w[i]); } if(M==N) noCycle=false; else noCycle=true; } /* 5 4 1 2 3 2 3 4 3 4 5 4 5 6 4 1 2 1 5 2 5 2 4 */ int getMinimumFuelCapacity(int x, int y) { if(n<=3) return -1; int ans = 0; if(x==0){ S.erase(S.find(wei[y])); ans = wei[y]; ans = max({ans, *S.begin(), *next(S.begin())}); S.insert(wei[y]); } else{ S.erase(S.find(wei[x])); S.erase(S.find(wei[y])); ans = max(wei[x],wei[y]); ans = max(ans, *S.begin()); S.insert(wei[x]); S.insert(wei[y]); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...