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 <vector>
#include <algorithm>
using namespace std;
const int MAXN = 1e5 + 123;
int n;
vector<pair<int, int>> edg[MAXN];
void init(int N, int m, vector<int> U, vector<int> V, vector<int> W) {
n = N;
vector<pair<int, pair<int, int>>> edg_weight(m);
for (int i = 0; i < m; ++i) {
edg_weight[i] = {W[i], {U[i], V[i]}};
}
sort(edg_weight.begin(), edg_weight.end());
for (auto [w, e] : edg_weight) {
auto [u, v] = e;
edg[u].push_back({v, w});
edg[v].push_back({u, w});
}
}
int getMinimumFuelCapacity(int X, int Y) {
if (edg[0].size() < n - 1)
return -1;
if (edg[0].size() < 3)
return -1;
if (X == 0) {
return max(edg[0][2].second, edg[Y][0].second);
}
if (Y == 0)
return getMinimumFuelCapacity(Y, X);
return max({edg[0][2].second, edg[X][0].second, edg[Y][0].second});
}
Compilation message (stderr)
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:25:23: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
25 | if (edg[0].size() < n - 1)
| ~~~~~~~~~~~~~~^~~~~~~
# | 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... |