Submission #1225960

#TimeUsernameProblemLanguageResultExecution timeMemory
1225960paskalisapoSwapping Cities (APIO20_swap)C++20
0 / 100
47 ms6112 KiB
#include "swap.h" #include<bits/stdc++.h> #include <vector> using namespace std; int citiesnum , roadnum; vector<vector<pair<int,int>>> adj; int ind1, ind2, ind3; int w1, w2, w3; vector<int> wtonode; bool skip = false; void init(int N, int M, std::vector<int> U, std::vector<int> V, std::vector<int> W) { if(N <= 3) { skip = true; return; } citiesnum = N; roadnum = M; priority_queue<pair<int,int>> q; wtonode.resize(N , -1); for(int i = 0 ;i < M ;i++) { if(q.size() < 3) { q.push({W[i], V[i]}); } else if(q.top().first > W[i]) { q.pop(); q.push({W[i], V[i]}); } wtonode[V[i]] = W[i]; } ind1 = q.top().second; w1 = q.top().first; q.pop(); ind2 = q.top().second; w2 = q.top().first; q.pop(); ind3= q.top().second; w3 = q.top().first; q.pop(); } int getMinimumFuelCapacity(int X, int Y) { if(skip) { return -1; } int other = w3; int value1 = wtonode[X]; int value2 = wtonode[Y]; if(X == 0) { value1 = w3; other = w2; } if(Y == 0) { value2 = w3; other = w2; } if(X == ind3 || Y == ind3) { other = w2; if(X == 0) { value1 = w2; other = w1; } if(Y == 0) { value2 = w2; other = w1; } if(X == ind2 || Y == ind2) { other = w1; } } int answer = max(value1, max(value2, other)); return answer; }
#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...