#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int nax = 100005;
int N, M;
vector<pair<int, pair<int, int>>> edges; // (W, (U, V))
int to[nax];
void init(int _N, int _M, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
N = _N; M = _M;
for (int i = 0; i < M; i++) {
edges.push_back(make_pair(W[i], make_pair(U[i], V[i])));
to[V[i]] = W[i];
}
sort(edges.begin(), edges.end());
}
int getMinimumFuelCapacity(int X, int Y) {
if (N <= 3) return -1;
if (X > Y) swap(X, Y);
if (X == 0) {
int cnt = 0, mx = to[Y];
for (int i = 0; i < M; i++) {
if (edges[i].second.second != Y) {
cnt++;
mx = max(mx, edges[i].first);
if (cnt >= 2) return mx;
}
}
}
else {
for (int i = 0; i < M; i++) {
if (edges[i].second.first != X && edges[i].second.second != Y) {
return max({to[X], to[Y], edges[i].first});
}
}
}
}
// #include "grader.cpp"
Compilation message
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type]
40 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
88 ms |
6964 KB |
Output is correct |
4 |
Correct |
81 ms |
11056 KB |
Output is correct |
5 |
Incorrect |
76 ms |
11616 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |