Submission #407335

#TimeUsernameProblemLanguageResultExecution timeMemory
407335promaSwapping Cities (APIO20_swap)C++17
7 / 100
113 ms10896 KiB
#include <bits/stdc++.h> using namespace std; int n; vector <pair <int, int>> edge; vector <int> weight; void init (int N, int M, vector<int> U, vector<int> V, vector<int> W) { n = N; weight.resize(N); for (int i = 0; i < M; i ++) { edge.push_back({W[i], V[i]}); weight[V[i]] = W[i]; } sort(edge.begin(), edge.end()); } int getMinimumFuelCapacity (int X, int Y) { if (n < 4) { return -1; } if (!X or !Y) { int max_weight = weight[Y]; int cnt = 0; for (auto i: edge) { if (i.second != Y) { max_weight = max(max_weight, i.first); cnt ++; } if (cnt == 2) { break; } } return max_weight; } else { int max_weight = max(weight[X], weight[Y]); for (auto i: edge) { if (i.second != X and i.second != Y) { max_weight = max(max_weight, i.first); break; } } return max_weight; } }
#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...