Submission #963211

#TimeUsernameProblemLanguageResultExecution timeMemory
963211SuPythonySwapping Cities (APIO20_swap)C++17
0 / 100
101 ms16932 KiB
#include "swap.h" #include <bits/stdc++.h> using namespace std; vector<vector<pair<int,int>>> al; int n,m; vector<pair<int,int>> ew; vector<int> ew2; void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) { al.assign(N+1,vector<pair<int,int>>()); ew2.assign(N+1,0); for (int i=0; i<M; i++) { al[U[i]].push_back({V[i],W[i]}); al[V[i]].push_back({U[i],W[i]}); ew.push_back({W[i],V[i]}); ew2[V[i]]=W[i]; } n=N; m=M; sort(ew.begin(),ew.end()); } int getMinimumFuelCapacity(int X, int Y) { if (m<=2) return -1; if (ew[0].second==X||ew[0].second==Y) { if (ew[1].second==X||ew[1].second==Y) { return max({ew[2].first,ew2[X],ew2[Y]}); } return max({ew[1].first,ew2[X],ew2[Y]}); } return max({ew[0].first,ew2[X],ew2[Y]}); }
#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...