#include "swap.h"
#include<bits/stdc++.h>
#include <vector>
using namespace std;
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;
}
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 answer;
if(Y == 0) {
swap(X , Y);
}
if(X == 0) {
int answer;
if(Y == ind2 || Y == ind3) {
answer = w1;
}
else {
answer = wtonode[Y];
}
return answer;
}
if(Y == ind2 || Y == ind3) {
if(X == ind2 || X == ind3) {
answer = w1;
}
answer = wtonode[X];
}
else {
answer = max(wtonode[X], wtonode[Y]);
}
return answer;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |