This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
int i, n;
bool visited[100005];
int we[100005];
pair<int, int> tw[100005];
bool cycle;
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
n = N;
for (i=0; i < M; ++i) tw[i] = make_pair(W[i], V[i]);
sort(tw, tw+M);
for (i=0; i < M; ++i) we[V[i]] = W[i];
}
int getMinimumFuelCapacity(int X, int Y) {
if (n <= 3) return -1;
if (X == 0) {
int cc = 0;
int ans = we[Y];
for (i=0; i < 3; ++i) {
if (tw[i].second == Y) continue;
++cc;
ans = max(ans, tw[i].first);
if (cc == 2) return ans;
}
}
else for (i=0; i < 3; ++i) if (tw[i].second != X && tw[i].second != Y) return max({we[X], we[Y], tw[i].first});
}
Compilation message (stderr)
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
33 | }
| ^
# | 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... |