#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
vector<tuple<int,int,int>> edg;
void init(int N,int M,vector<int>U,vector<int>V,vector<int>W) {
for(int i=0;i<M;i++)
edg.push_back({W[i],++U[i],++V[i]});
sort(edg.begin(),edg.end());
}
int par[100100],deg[100100];
bitset<100100>yes;
int abp(int n){
return par[n]?par[n]=abp(par[n]):n;
}
int getMinimumFuelCapacity(int X,int Y) {
yes.reset(); ++X,++Y;
memset(par,0,sizeof par);
memset(deg,0,sizeof deg);
for(auto[w,u,v]:edg){
deg[u]++,deg[v]++;
if(deg[u]>2)
yes[abp(v)]=1;
if(deg[v]>2)
yes[abp(v)]=1;
u=abp(u),v=abp(v);
if(u-v) par[u]=v,
yes[v]=yes[v]|yes[u];
else yes[v]=1;
if(abp(X)==abp(Y)&&yes[abp(X)])
return w;
}
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1116 KB |
Output is correct |
9 |
Correct |
24 ms |
5452 KB |
Output is correct |
10 |
Correct |
31 ms |
6356 KB |
Output is correct |
11 |
Correct |
32 ms |
6092 KB |
Output is correct |
12 |
Correct |
35 ms |
6464 KB |
Output is correct |
13 |
Correct |
53 ms |
6460 KB |
Output is correct |
14 |
Execution timed out |
2028 ms |
5956 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Execution timed out |
2041 ms |
9416 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1116 KB |
Output is correct |
9 |
Correct |
1 ms |
1116 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1116 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1224 KB |
Output is correct |
14 |
Correct |
1 ms |
1116 KB |
Output is correct |
15 |
Correct |
1 ms |
1116 KB |
Output is correct |
16 |
Correct |
1 ms |
1116 KB |
Output is correct |
17 |
Correct |
1 ms |
1116 KB |
Output is correct |
18 |
Correct |
2 ms |
1116 KB |
Output is correct |
19 |
Correct |
1 ms |
1304 KB |
Output is correct |
20 |
Correct |
1 ms |
1116 KB |
Output is correct |
21 |
Correct |
1 ms |
1116 KB |
Output is correct |
22 |
Correct |
1 ms |
1228 KB |
Output is correct |
23 |
Correct |
1 ms |
1116 KB |
Output is correct |
24 |
Correct |
1 ms |
1116 KB |
Output is correct |
25 |
Correct |
1 ms |
1116 KB |
Output is correct |
26 |
Correct |
1 ms |
1116 KB |
Output is correct |
27 |
Correct |
1 ms |
1116 KB |
Output is correct |
28 |
Correct |
1 ms |
1116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1116 KB |
Output is correct |
9 |
Correct |
1 ms |
1116 KB |
Output is correct |
10 |
Correct |
24 ms |
5452 KB |
Output is correct |
11 |
Correct |
31 ms |
6356 KB |
Output is correct |
12 |
Correct |
32 ms |
6092 KB |
Output is correct |
13 |
Correct |
35 ms |
6464 KB |
Output is correct |
14 |
Correct |
53 ms |
6460 KB |
Output is correct |
15 |
Correct |
1 ms |
1116 KB |
Output is correct |
16 |
Correct |
1 ms |
1116 KB |
Output is correct |
17 |
Correct |
1 ms |
1116 KB |
Output is correct |
18 |
Correct |
1 ms |
1224 KB |
Output is correct |
19 |
Correct |
1 ms |
1116 KB |
Output is correct |
20 |
Correct |
1 ms |
1116 KB |
Output is correct |
21 |
Correct |
1 ms |
1116 KB |
Output is correct |
22 |
Correct |
1 ms |
1116 KB |
Output is correct |
23 |
Correct |
2 ms |
1116 KB |
Output is correct |
24 |
Correct |
1 ms |
1304 KB |
Output is correct |
25 |
Correct |
1 ms |
1116 KB |
Output is correct |
26 |
Correct |
1 ms |
1116 KB |
Output is correct |
27 |
Correct |
1 ms |
1228 KB |
Output is correct |
28 |
Correct |
1 ms |
1116 KB |
Output is correct |
29 |
Correct |
1 ms |
1116 KB |
Output is correct |
30 |
Correct |
1 ms |
1116 KB |
Output is correct |
31 |
Correct |
1 ms |
1116 KB |
Output is correct |
32 |
Correct |
1 ms |
1116 KB |
Output is correct |
33 |
Correct |
1 ms |
1116 KB |
Output is correct |
34 |
Correct |
7 ms |
2072 KB |
Output is correct |
35 |
Correct |
35 ms |
6204 KB |
Output is correct |
36 |
Correct |
36 ms |
6296 KB |
Output is correct |
37 |
Correct |
58 ms |
6076 KB |
Output is correct |
38 |
Correct |
32 ms |
6180 KB |
Output is correct |
39 |
Correct |
32 ms |
6092 KB |
Output is correct |
40 |
Correct |
33 ms |
5844 KB |
Output is correct |
41 |
Correct |
34 ms |
6344 KB |
Output is correct |
42 |
Correct |
33 ms |
6100 KB |
Output is correct |
43 |
Correct |
29 ms |
6100 KB |
Output is correct |
44 |
Correct |
42 ms |
6352 KB |
Output is correct |
45 |
Correct |
67 ms |
10184 KB |
Output is correct |
46 |
Correct |
34 ms |
6096 KB |
Output is correct |
47 |
Correct |
46 ms |
6092 KB |
Output is correct |
48 |
Correct |
39 ms |
6608 KB |
Output is correct |
49 |
Correct |
40 ms |
9936 KB |
Output is correct |
50 |
Correct |
32 ms |
7112 KB |
Output is correct |
51 |
Correct |
74 ms |
7812 KB |
Output is correct |
52 |
Correct |
51 ms |
10696 KB |
Output is correct |
53 |
Correct |
54 ms |
11596 KB |
Output is correct |
54 |
Correct |
60 ms |
12228 KB |
Output is correct |
55 |
Correct |
30 ms |
6096 KB |
Output is correct |
56 |
Correct |
73 ms |
11272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1116 KB |
Output is correct |
9 |
Correct |
24 ms |
5452 KB |
Output is correct |
10 |
Correct |
31 ms |
6356 KB |
Output is correct |
11 |
Correct |
32 ms |
6092 KB |
Output is correct |
12 |
Correct |
35 ms |
6464 KB |
Output is correct |
13 |
Correct |
53 ms |
6460 KB |
Output is correct |
14 |
Execution timed out |
2028 ms |
5956 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1116 KB |
Output is correct |
9 |
Correct |
1 ms |
1116 KB |
Output is correct |
10 |
Correct |
24 ms |
5452 KB |
Output is correct |
11 |
Correct |
31 ms |
6356 KB |
Output is correct |
12 |
Correct |
32 ms |
6092 KB |
Output is correct |
13 |
Correct |
35 ms |
6464 KB |
Output is correct |
14 |
Correct |
53 ms |
6460 KB |
Output is correct |
15 |
Execution timed out |
2028 ms |
5956 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |