Submission #979510

#TimeUsernameProblemLanguageResultExecution timeMemory
979510stegatxins0Swapping Cities (APIO20_swap)C++17
7 / 100
76 ms7004 KiB
#include <bits/stdc++.h> #include "swap.h" using namespace std; #ifdef DEBUG #include "debug.cpp" #else #define dbg(...) #define dbgarr(...) #endif const int mxN = 1e5+1; vector<pair<int,int>> edge; int to[mxN],N,M; 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++){ edge.push_back({W[i], V[i]}); to[V[i]] = W[i]; } sort(edge.begin(), edge.end()); } int getMinimumFuelCapacity(int X, int Y) { if(N < 4)return -1; if(X > Y)swap(X,Y); if(X == 0){ int cnt = 0; for(int i=0; i<M; i++){ if(edge[i].second != Y){ cnt++; if(cnt >= 2){ return max(edge[i].first, to[Y]); } } } } for(int i=0; i<M; i++){ if(edge[i].second != X && edge[i].second != Y){ return max({to[X], to[Y], edge[i].first}); } } return -1; }
#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...