Submission #569755

#TimeUsernameProblemLanguageResultExecution timeMemory
569755sumit_kk10Swapping Cities (APIO20_swap)C++17
6 / 100
2075 ms32412 KiB
#include "swap.h" #include<bits/stdc++.h> #include <vector> #define pb push_back using namespace std; const int N = 1e6 + 5; vector<pair<int, int> > g[N]; int mx, n, m; bool sb2 = 1; void init(int N, int M, std::vector<int> U, std::vector<int> V, std::vector<int> W) { n = N; m = M; for(int i = 0; i < M; ++i){ int u = U[i], v = V[i], w = W[i]; if(u != 0) sb2 = false; g[u].pb({v, w}); g[v].pb({u, w}); mx = max(mx, w); } } int getMinimumFuelCapacity(int X, int Y) { if(sb2 and m == n - 1){ int x = g[X][0].second, xx = g[Y][0].second, mn = INT_MAX; for(auto k : g[0]){ if(k.first != X and k.first != Y) mn = min(mn, k.second); } if(mn == INT_MAX) return -1; return max({x, xx, mn}); } if(m == n - 1) return -1; else return mx; }
#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...