#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
#define fi first
#define se second
const int INF = 1e9+1;
const int P = 1000000007;
const ll LLINF = (ll)1e18+1;
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) { os << p.fi << " " << p.se; return os; }
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) { for(auto i : v) os << i << " "; os << "\n"; return os; }
struct UF {
vector<int> P, A, B, C;
int fin(int x) {
if(P[x] == x) return x;
else return P[x] = fin(P[x]);
}
int max_deg(int x) {
return B[fin(x)];
}
void mer(int x, int y) {
//cout << x << " " << y << "\n";
int xx = fin(x), yy = fin(y);
if(xx != yy) P[yy] = xx;
else C[xx] = 1;
B[xx] = max(max(B[xx], B[yy]), max(++A[x], ++A[y]));
C[xx] = C[xx] || C[yy];
}
UF(int n) {
A.resize(n, 0), B.resize(n, 0), C.resize(n, 0);
for(int i = 0; i < n; i++) P.push_back(i);
}
};
int n, m;
vector<piii> E;
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
n = N, m = M, E.resize(M);
for(int i = 0; i < M; i++) E[i] = {W[i], {U[i], V[i]}};
sort(E.begin(), E.end());
}
int getMinimumFuelCapacity(int X, int Y) {
UF uf(n);
for(int i = 0; i < m; i++) {
uf.mer(E[i].se.fi, E[i].se.se);
//cout << uf.A << uf.B << uf.C << uf.P << "\n";
if(uf.fin(X) == uf.fin(Y) && (uf.B[uf.fin(X)] >= 3 || uf.C[uf.fin(X)])) return E[i].fi;
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
300 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
37 ms |
5484 KB |
Output is correct |
10 |
Correct |
53 ms |
6568 KB |
Output is correct |
11 |
Correct |
58 ms |
6468 KB |
Output is correct |
12 |
Correct |
61 ms |
6772 KB |
Output is correct |
13 |
Correct |
67 ms |
7228 KB |
Output is correct |
14 |
Execution timed out |
2086 ms |
6044 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
300 KB |
Output is correct |
3 |
Execution timed out |
2067 ms |
10892 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
300 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
312 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
316 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
316 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
312 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
360 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 |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
37 ms |
5484 KB |
Output is correct |
11 |
Correct |
53 ms |
6568 KB |
Output is correct |
12 |
Correct |
58 ms |
6468 KB |
Output is correct |
13 |
Correct |
61 ms |
6772 KB |
Output is correct |
14 |
Correct |
67 ms |
7228 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
312 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
316 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
316 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
2 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
312 KB |
Output is correct |
31 |
Correct |
2 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
360 KB |
Output is correct |
34 |
Correct |
6 ms |
1180 KB |
Output is correct |
35 |
Correct |
59 ms |
6584 KB |
Output is correct |
36 |
Correct |
57 ms |
6552 KB |
Output is correct |
37 |
Correct |
64 ms |
6672 KB |
Output is correct |
38 |
Correct |
62 ms |
6436 KB |
Output is correct |
39 |
Correct |
60 ms |
6420 KB |
Output is correct |
40 |
Correct |
57 ms |
5976 KB |
Output is correct |
41 |
Correct |
74 ms |
6804 KB |
Output is correct |
42 |
Correct |
61 ms |
6476 KB |
Output is correct |
43 |
Correct |
49 ms |
6548 KB |
Output is correct |
44 |
Correct |
64 ms |
6812 KB |
Output is correct |
45 |
Correct |
81 ms |
8600 KB |
Output is correct |
46 |
Correct |
62 ms |
6544 KB |
Output is correct |
47 |
Correct |
62 ms |
6488 KB |
Output is correct |
48 |
Correct |
65 ms |
6864 KB |
Output is correct |
49 |
Correct |
60 ms |
8544 KB |
Output is correct |
50 |
Correct |
43 ms |
6732 KB |
Output is correct |
51 |
Correct |
62 ms |
7480 KB |
Output is correct |
52 |
Correct |
84 ms |
9496 KB |
Output is correct |
53 |
Correct |
88 ms |
10392 KB |
Output is correct |
54 |
Correct |
101 ms |
11320 KB |
Output is correct |
55 |
Correct |
53 ms |
6556 KB |
Output is correct |
56 |
Correct |
97 ms |
10024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
300 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
37 ms |
5484 KB |
Output is correct |
10 |
Correct |
53 ms |
6568 KB |
Output is correct |
11 |
Correct |
58 ms |
6468 KB |
Output is correct |
12 |
Correct |
61 ms |
6772 KB |
Output is correct |
13 |
Correct |
67 ms |
7228 KB |
Output is correct |
14 |
Execution timed out |
2086 ms |
6044 KB |
Time limit exceeded |
15 |
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 |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
37 ms |
5484 KB |
Output is correct |
11 |
Correct |
53 ms |
6568 KB |
Output is correct |
12 |
Correct |
58 ms |
6468 KB |
Output is correct |
13 |
Correct |
61 ms |
6772 KB |
Output is correct |
14 |
Correct |
67 ms |
7228 KB |
Output is correct |
15 |
Execution timed out |
2086 ms |
6044 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |