#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
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)
| ~~~~~~~~~~~~~~^~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2516 KB |
Output is correct |
2 |
Correct |
2 ms |
2516 KB |
Output is correct |
3 |
Correct |
1 ms |
2516 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2588 KB |
Output is correct |
9 |
Correct |
44 ms |
7920 KB |
Output is correct |
10 |
Correct |
50 ms |
9016 KB |
Output is correct |
11 |
Correct |
49 ms |
8908 KB |
Output is correct |
12 |
Correct |
52 ms |
9248 KB |
Output is correct |
13 |
Correct |
50 ms |
9196 KB |
Output is correct |
14 |
Correct |
44 ms |
8004 KB |
Output is correct |
15 |
Correct |
109 ms |
10580 KB |
Output is correct |
16 |
Correct |
105 ms |
10452 KB |
Output is correct |
17 |
Correct |
107 ms |
10856 KB |
Output is correct |
18 |
Correct |
106 ms |
10764 KB |
Output is correct |
19 |
Incorrect |
52 ms |
5776 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2516 KB |
Output is correct |
2 |
Correct |
2 ms |
2516 KB |
Output is correct |
3 |
Correct |
106 ms |
11492 KB |
Output is correct |
4 |
Correct |
98 ms |
11720 KB |
Output is correct |
5 |
Correct |
108 ms |
11884 KB |
Output is correct |
6 |
Correct |
100 ms |
11572 KB |
Output is correct |
7 |
Correct |
109 ms |
11960 KB |
Output is correct |
8 |
Correct |
103 ms |
11608 KB |
Output is correct |
9 |
Correct |
100 ms |
11636 KB |
Output is correct |
10 |
Correct |
99 ms |
11516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2516 KB |
Output is correct |
2 |
Correct |
2 ms |
2516 KB |
Output is correct |
3 |
Correct |
1 ms |
2516 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2588 KB |
Output is correct |
9 |
Incorrect |
1 ms |
2516 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2516 KB |
Output is correct |
2 |
Correct |
2 ms |
2516 KB |
Output is correct |
3 |
Correct |
1 ms |
2516 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2588 KB |
Output is correct |
9 |
Correct |
44 ms |
7920 KB |
Output is correct |
10 |
Correct |
50 ms |
9016 KB |
Output is correct |
11 |
Correct |
49 ms |
8908 KB |
Output is correct |
12 |
Correct |
52 ms |
9248 KB |
Output is correct |
13 |
Correct |
50 ms |
9196 KB |
Output is correct |
14 |
Correct |
44 ms |
8004 KB |
Output is correct |
15 |
Correct |
109 ms |
10580 KB |
Output is correct |
16 |
Correct |
105 ms |
10452 KB |
Output is correct |
17 |
Correct |
107 ms |
10856 KB |
Output is correct |
18 |
Correct |
106 ms |
10764 KB |
Output is correct |
19 |
Correct |
106 ms |
11492 KB |
Output is correct |
20 |
Correct |
98 ms |
11720 KB |
Output is correct |
21 |
Correct |
108 ms |
11884 KB |
Output is correct |
22 |
Correct |
100 ms |
11572 KB |
Output is correct |
23 |
Correct |
109 ms |
11960 KB |
Output is correct |
24 |
Correct |
103 ms |
11608 KB |
Output is correct |
25 |
Correct |
100 ms |
11636 KB |
Output is correct |
26 |
Correct |
99 ms |
11516 KB |
Output is correct |
27 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |