Submission #1225922

#TimeUsernameProblemLanguageResultExecution timeMemory
1225922paskalisapoSwapping Cities (APIO20_swap)C++20
0 / 100
1 ms320 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; void init(int N, int M, std::vector<int> U, std::vector<int> V, std::vector<int> W) { citiesnum = N; roadnum = M; priority_queue<pair<int,int>> q; wtonode.resize(N , -1); for(int i = 0 ;i < M ;i++) { if(q.top().first > W[i] || q.size() < 3) { 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) { int other = w3; if(X == ind3 || Y == ind3) { other = w2; if(X == ind2 || Y == ind2) { other = w1; } } if(wtonode[X] == -1 || wtonode[Y] == -1) { return -1; } int answer = max(wtonode[X], max(wtonode[Y], 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...