#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
int i,j,s,t;
int link[261523],size[234567],c[234567],a[234567],l=12345678,r,tt,k,y,z,n,m,x;
pair<int,pair<int,int>>p[234567];
void init(int N, int M, vector <int> U, vector <int> V, vector <int> W) {
n = N;
m = M;
for (i = 0; i <m; i ++){
p[i].first=W[i];
p[i].second.first=U[i];
p[i].second.second=V[i];
}
sort (p,p+m);
}
int find(int x) {
if(x==link[x])return x;
else return link[x]=find(link[x]);
}
bool same(int x, int y) {
return find(x) == find(y);
}
void unite(int x, int y) {
x = find(x);
y = find(y);
if (size[x] < size[y])
swap(x,y);
size[x] += size[y];
if (c[y]==1)
c[x]=1;
link[y] = x;
}
int getMinimumFuelCapacity(int u, int v) {
for (i = 0; i<n; i ++){
link[i]=i;
size[i]=1;
c[i]=0;
a[i]=0;
}
for (i = 0; i <m; i ++){
x=p[i].second.first;
y=p[i].second.second;
a[x]++;
a[y]++;
if (find(x)==find(y)||a[x]>2||a[y]>2){
c[find(x)]=1;
c[find(y)]=1;
}
unite(x,y);
if (find(u)==find(v)&&c[find(u)]==1){
return p[i].first;
}
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
45 ms |
3380 KB |
Output is correct |
10 |
Correct |
61 ms |
4060 KB |
Output is correct |
11 |
Correct |
66 ms |
3904 KB |
Output is correct |
12 |
Correct |
70 ms |
4244 KB |
Output is correct |
13 |
Correct |
67 ms |
4144 KB |
Output is correct |
14 |
Execution timed out |
2090 ms |
3512 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Execution timed out |
2082 ms |
6320 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
336 KB |
Output is correct |
19 |
Correct |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
45 ms |
3380 KB |
Output is correct |
11 |
Correct |
61 ms |
4060 KB |
Output is correct |
12 |
Correct |
66 ms |
3904 KB |
Output is correct |
13 |
Correct |
70 ms |
4244 KB |
Output is correct |
14 |
Correct |
67 ms |
4144 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
2 ms |
336 KB |
Output is correct |
24 |
Correct |
2 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
2 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
2 ms |
332 KB |
Output is correct |
30 |
Correct |
2 ms |
332 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
1 ms |
332 KB |
Output is correct |
33 |
Correct |
2 ms |
332 KB |
Output is correct |
34 |
Correct |
7 ms |
940 KB |
Output is correct |
35 |
Correct |
67 ms |
4144 KB |
Output is correct |
36 |
Correct |
67 ms |
4148 KB |
Output is correct |
37 |
Correct |
74 ms |
4268 KB |
Output is correct |
38 |
Correct |
68 ms |
4196 KB |
Output is correct |
39 |
Correct |
67 ms |
4144 KB |
Output is correct |
40 |
Correct |
62 ms |
3760 KB |
Output is correct |
41 |
Correct |
70 ms |
4188 KB |
Output is correct |
42 |
Correct |
68 ms |
4148 KB |
Output is correct |
43 |
Correct |
54 ms |
4148 KB |
Output is correct |
44 |
Correct |
74 ms |
4140 KB |
Output is correct |
45 |
Correct |
92 ms |
5360 KB |
Output is correct |
46 |
Correct |
68 ms |
6060 KB |
Output is correct |
47 |
Correct |
71 ms |
5932 KB |
Output is correct |
48 |
Correct |
73 ms |
6436 KB |
Output is correct |
49 |
Correct |
69 ms |
8760 KB |
Output is correct |
50 |
Correct |
54 ms |
6852 KB |
Output is correct |
51 |
Correct |
76 ms |
7432 KB |
Output is correct |
52 |
Correct |
99 ms |
9352 KB |
Output is correct |
53 |
Correct |
126 ms |
10292 KB |
Output is correct |
54 |
Correct |
116 ms |
11204 KB |
Output is correct |
55 |
Correct |
59 ms |
6052 KB |
Output is correct |
56 |
Correct |
124 ms |
9984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
45 ms |
3380 KB |
Output is correct |
10 |
Correct |
61 ms |
4060 KB |
Output is correct |
11 |
Correct |
66 ms |
3904 KB |
Output is correct |
12 |
Correct |
70 ms |
4244 KB |
Output is correct |
13 |
Correct |
67 ms |
4144 KB |
Output is correct |
14 |
Execution timed out |
2090 ms |
3512 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
45 ms |
3380 KB |
Output is correct |
11 |
Correct |
61 ms |
4060 KB |
Output is correct |
12 |
Correct |
66 ms |
3904 KB |
Output is correct |
13 |
Correct |
70 ms |
4244 KB |
Output is correct |
14 |
Correct |
67 ms |
4144 KB |
Output is correct |
15 |
Execution timed out |
2090 ms |
3512 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |