#include "swap.h"
#include<bits/stdc++.h>
#include <vector>
#define pb push_back
using namespace std;
const int N = 1e6 + 5;
vector<pair<int, int> > g[N];
int mx, n, m;
bool sb2 = 1;
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){
int u = U[i], v = V[i], w = W[i];
if(u != 0 and v != 0)
sb2 = false;
g[u].pb({w, v});
g[v].pb({w, u});
mx = max(mx, w);
}
for(int i = 0; i < n; ++i)
sort(g[i].begin(), g[i].end());
}
int getMinimumFuelCapacity(int X, int Y) {
if(sb2 and m == n - 1){
if(n <= 3) return -1;
if(X == 0){
int x = g[Y][0].first, xx, dest, mn;
if(g[0][0].second != Y){
xx = g[0][0].first;
dest = g[0][0].second;
}else{
xx = g[0][1].first;
dest = g[0][1].second;
}
if(g[0][1].second != Y and g[0][1].second != dest)
mn = g[0][1].first;
else
mn = g[0][2].first;
return max({x, xx, mn});
}
int x = g[X][0].first, xx = g[Y][0].first, mn;
if(g[0][0].second != X and g[0][0].second != Y)
mn = g[0][0].first;
else if(g[0][1].second != X and g[0][1].second != Y)
mn = g[0][1].first;
else
mn = g[0][2].first;
return max({x, xx, mn});
}
if(m == n - 1)
return -1;
else
return mx;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23704 KB |
Output is correct |
2 |
Correct |
12 ms |
23728 KB |
Output is correct |
3 |
Correct |
13 ms |
23788 KB |
Output is correct |
4 |
Correct |
12 ms |
23720 KB |
Output is correct |
5 |
Correct |
12 ms |
23764 KB |
Output is correct |
6 |
Correct |
14 ms |
23792 KB |
Output is correct |
7 |
Correct |
14 ms |
23764 KB |
Output is correct |
8 |
Correct |
12 ms |
23764 KB |
Output is correct |
9 |
Correct |
51 ms |
28040 KB |
Output is correct |
10 |
Correct |
56 ms |
29000 KB |
Output is correct |
11 |
Correct |
57 ms |
28848 KB |
Output is correct |
12 |
Correct |
58 ms |
29192 KB |
Output is correct |
13 |
Correct |
71 ms |
29308 KB |
Output is correct |
14 |
Correct |
56 ms |
28160 KB |
Output is correct |
15 |
Correct |
116 ms |
30828 KB |
Output is correct |
16 |
Correct |
109 ms |
30668 KB |
Output is correct |
17 |
Correct |
114 ms |
30952 KB |
Output is correct |
18 |
Correct |
117 ms |
30992 KB |
Output is correct |
19 |
Correct |
64 ms |
28052 KB |
Output is correct |
20 |
Correct |
112 ms |
31948 KB |
Output is correct |
21 |
Correct |
113 ms |
32136 KB |
Output is correct |
22 |
Correct |
121 ms |
32424 KB |
Output is correct |
23 |
Correct |
110 ms |
32364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23704 KB |
Output is correct |
2 |
Correct |
12 ms |
23728 KB |
Output is correct |
3 |
Correct |
108 ms |
32736 KB |
Output is correct |
4 |
Correct |
118 ms |
33388 KB |
Output is correct |
5 |
Correct |
121 ms |
33496 KB |
Output is correct |
6 |
Correct |
115 ms |
33276 KB |
Output is correct |
7 |
Correct |
115 ms |
33508 KB |
Output is correct |
8 |
Correct |
116 ms |
33264 KB |
Output is correct |
9 |
Correct |
114 ms |
33372 KB |
Output is correct |
10 |
Correct |
120 ms |
33148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23704 KB |
Output is correct |
2 |
Correct |
12 ms |
23728 KB |
Output is correct |
3 |
Correct |
13 ms |
23788 KB |
Output is correct |
4 |
Correct |
12 ms |
23720 KB |
Output is correct |
5 |
Correct |
12 ms |
23764 KB |
Output is correct |
6 |
Correct |
14 ms |
23792 KB |
Output is correct |
7 |
Correct |
14 ms |
23764 KB |
Output is correct |
8 |
Correct |
12 ms |
23764 KB |
Output is correct |
9 |
Incorrect |
12 ms |
23756 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
23756 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23704 KB |
Output is correct |
2 |
Correct |
12 ms |
23728 KB |
Output is correct |
3 |
Correct |
13 ms |
23788 KB |
Output is correct |
4 |
Correct |
12 ms |
23720 KB |
Output is correct |
5 |
Correct |
12 ms |
23764 KB |
Output is correct |
6 |
Correct |
14 ms |
23792 KB |
Output is correct |
7 |
Correct |
14 ms |
23764 KB |
Output is correct |
8 |
Correct |
12 ms |
23764 KB |
Output is correct |
9 |
Correct |
51 ms |
28040 KB |
Output is correct |
10 |
Correct |
56 ms |
29000 KB |
Output is correct |
11 |
Correct |
57 ms |
28848 KB |
Output is correct |
12 |
Correct |
58 ms |
29192 KB |
Output is correct |
13 |
Correct |
71 ms |
29308 KB |
Output is correct |
14 |
Correct |
56 ms |
28160 KB |
Output is correct |
15 |
Correct |
116 ms |
30828 KB |
Output is correct |
16 |
Correct |
109 ms |
30668 KB |
Output is correct |
17 |
Correct |
114 ms |
30952 KB |
Output is correct |
18 |
Correct |
117 ms |
30992 KB |
Output is correct |
19 |
Correct |
108 ms |
32736 KB |
Output is correct |
20 |
Correct |
118 ms |
33388 KB |
Output is correct |
21 |
Correct |
121 ms |
33496 KB |
Output is correct |
22 |
Correct |
115 ms |
33276 KB |
Output is correct |
23 |
Correct |
115 ms |
33508 KB |
Output is correct |
24 |
Correct |
116 ms |
33264 KB |
Output is correct |
25 |
Correct |
114 ms |
33372 KB |
Output is correct |
26 |
Correct |
120 ms |
33148 KB |
Output is correct |
27 |
Incorrect |
13 ms |
23764 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
23756 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |