#include "swap.h"
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define int long long
const int NN = 1e5+5;
int mx = 0, ok, res, d[NN], n, m;
vector<pair<int, int>> edges[NN];
vector<pair<int, int>> mm;
void init(int32_t N, int32_t M,
vector<int32_t> a, vector<int32_t> b, vector<int32_t> c) {
n = N, m = M;
for(int i=0;i<m;i++){
edges[a[i]].pb({b[i], c[i]});
edges[b[i]].pb({a[i], c[i]});
mx = max(mx, (int)c[i]);
}
if(n == m) res = mx;
else {
res = -1;
ok = 1;
for(int i=0;i<m;i++) ok &= (min(a[i], b[i]) == 0);
if(ok){
for(int i=0;i<m;i++) d[max(a[i], b[i])] = c[i];
for(int i=1;i<n;i++) mm.pb({d[i], i});
sort(mm.begin(), mm.end());
mm.resize(3);
}
}
}
int32_t getMinimumFuelCapacity(int32_t x, int32_t y) {
if(!ok) return res;
if(x > y) swap(x, y);
if(n == 2) return -1;
if(x == 0){
if(y == mm[0].ss || y == mm[1].ss || y == mm[2].ss) return max({mm[0].ff, mm[1].ff, mm[2].ff});
else return max({d[y], mm[0].ff, mm[1].ff});
} else {
if(n == 3) return -1;
if((mm[0].ss == y || mm[1].ss == y) && (mm[0].ss == x || mm[1].ss == x)) return max({d[x], d[y], mm[2].ff});
else if(x == mm[0].ss || y == mm[0].ss) return max({d[x], d[y], mm[1].ff});
else return max({d[x], d[y], mm[0].ff});
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
3 ms |
2636 KB |
Output is correct |
5 |
Correct |
3 ms |
2688 KB |
Output is correct |
6 |
Correct |
4 ms |
2636 KB |
Output is correct |
7 |
Correct |
2 ms |
2636 KB |
Output is correct |
8 |
Correct |
2 ms |
2636 KB |
Output is correct |
9 |
Correct |
48 ms |
8568 KB |
Output is correct |
10 |
Correct |
74 ms |
9928 KB |
Output is correct |
11 |
Correct |
63 ms |
9756 KB |
Output is correct |
12 |
Correct |
68 ms |
10116 KB |
Output is correct |
13 |
Correct |
70 ms |
10180 KB |
Output is correct |
14 |
Correct |
66 ms |
8708 KB |
Output is correct |
15 |
Correct |
141 ms |
11780 KB |
Output is correct |
16 |
Correct |
128 ms |
11632 KB |
Output is correct |
17 |
Correct |
141 ms |
11908 KB |
Output is correct |
18 |
Correct |
169 ms |
11904 KB |
Output is correct |
19 |
Correct |
69 ms |
7292 KB |
Output is correct |
20 |
Correct |
163 ms |
12876 KB |
Output is correct |
21 |
Correct |
154 ms |
12908 KB |
Output is correct |
22 |
Correct |
130 ms |
13396 KB |
Output is correct |
23 |
Correct |
139 ms |
13408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
159 ms |
14620 KB |
Output is correct |
4 |
Correct |
128 ms |
18780 KB |
Output is correct |
5 |
Correct |
134 ms |
18800 KB |
Output is correct |
6 |
Correct |
124 ms |
18648 KB |
Output is correct |
7 |
Correct |
148 ms |
18856 KB |
Output is correct |
8 |
Correct |
122 ms |
18348 KB |
Output is correct |
9 |
Correct |
130 ms |
18632 KB |
Output is correct |
10 |
Correct |
130 ms |
18304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
3 ms |
2636 KB |
Output is correct |
5 |
Correct |
3 ms |
2688 KB |
Output is correct |
6 |
Correct |
4 ms |
2636 KB |
Output is correct |
7 |
Correct |
2 ms |
2636 KB |
Output is correct |
8 |
Correct |
2 ms |
2636 KB |
Output is correct |
9 |
Incorrect |
2 ms |
2636 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2636 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
3 ms |
2636 KB |
Output is correct |
5 |
Correct |
3 ms |
2688 KB |
Output is correct |
6 |
Correct |
4 ms |
2636 KB |
Output is correct |
7 |
Correct |
2 ms |
2636 KB |
Output is correct |
8 |
Correct |
2 ms |
2636 KB |
Output is correct |
9 |
Correct |
48 ms |
8568 KB |
Output is correct |
10 |
Correct |
74 ms |
9928 KB |
Output is correct |
11 |
Correct |
63 ms |
9756 KB |
Output is correct |
12 |
Correct |
68 ms |
10116 KB |
Output is correct |
13 |
Correct |
70 ms |
10180 KB |
Output is correct |
14 |
Correct |
66 ms |
8708 KB |
Output is correct |
15 |
Correct |
141 ms |
11780 KB |
Output is correct |
16 |
Correct |
128 ms |
11632 KB |
Output is correct |
17 |
Correct |
141 ms |
11908 KB |
Output is correct |
18 |
Correct |
169 ms |
11904 KB |
Output is correct |
19 |
Correct |
159 ms |
14620 KB |
Output is correct |
20 |
Correct |
128 ms |
18780 KB |
Output is correct |
21 |
Correct |
134 ms |
18800 KB |
Output is correct |
22 |
Correct |
124 ms |
18648 KB |
Output is correct |
23 |
Correct |
148 ms |
18856 KB |
Output is correct |
24 |
Correct |
122 ms |
18348 KB |
Output is correct |
25 |
Correct |
130 ms |
18632 KB |
Output is correct |
26 |
Correct |
130 ms |
18304 KB |
Output is correct |
27 |
Incorrect |
3 ms |
2636 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2636 KB |
Output isn't correct |