#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
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 |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
68 ms |
6600 KB |
Output is correct |
4 |
Correct |
70 ms |
10448 KB |
Output is correct |
5 |
Correct |
82 ms |
10824 KB |
Output is correct |
6 |
Correct |
69 ms |
10424 KB |
Output is correct |
7 |
Correct |
70 ms |
10780 KB |
Output is correct |
8 |
Correct |
68 ms |
10492 KB |
Output is correct |
9 |
Correct |
76 ms |
10484 KB |
Output is correct |
10 |
Correct |
68 ms |
10520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |