#include "swap.h"
#include<bits/stdc++.h>
#define pb push_back
#define ss second
#define ff first
using namespace std;
int l,r,i,j,ii,jj,k,n,m,mx,subtask=1;
vector< pair<int,int> > v[100000];
set< pair<int,int> > st;
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++){
v[U[i]].pb({V[i],W[i]});
v[V[i]].pb({U[i],W[i]});
mx=max(mx,W[i]);
st.insert({W[i],V[i]});
}
for(i=0;i<n;i++) if(v[i].size()>2) subtask=2;
}
int getMinimumFuelCapacity(int X, int Y) {
if(subtask==1){
if(n>m) return -1;
else return mx;
}
if(X==0 || Y==0 || n<=3) return -1;
st.erase({v[X][0].ss,X});
st.erase({v[Y][0].ss,Y});
mx=max(v[X][0].ss,v[Y][0].ss);
mx=max(mx,(*st.begin()).ff);
st.insert({v[X][0].ss,X});
st.insert({v[Y][0].ss,Y});
return mx;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2636 KB |
Output is correct |
9 |
Correct |
86 ms |
10636 KB |
Output is correct |
10 |
Correct |
127 ms |
12364 KB |
Output is correct |
11 |
Correct |
95 ms |
12172 KB |
Output is correct |
12 |
Correct |
112 ms |
12792 KB |
Output is correct |
13 |
Correct |
101 ms |
12776 KB |
Output is correct |
14 |
Correct |
81 ms |
10696 KB |
Output is correct |
15 |
Correct |
153 ms |
14256 KB |
Output is correct |
16 |
Correct |
216 ms |
13948 KB |
Output is correct |
17 |
Correct |
153 ms |
14496 KB |
Output is correct |
18 |
Correct |
150 ms |
14580 KB |
Output is correct |
19 |
Correct |
54 ms |
7680 KB |
Output is correct |
20 |
Correct |
143 ms |
15452 KB |
Output is correct |
21 |
Correct |
150 ms |
15312 KB |
Output is correct |
22 |
Correct |
197 ms |
15980 KB |
Output is correct |
23 |
Correct |
155 ms |
15956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Incorrect |
447 ms |
15940 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2636 KB |
Output is correct |
9 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2636 KB |
Output is correct |
9 |
Correct |
86 ms |
10636 KB |
Output is correct |
10 |
Correct |
127 ms |
12364 KB |
Output is correct |
11 |
Correct |
95 ms |
12172 KB |
Output is correct |
12 |
Correct |
112 ms |
12792 KB |
Output is correct |
13 |
Correct |
101 ms |
12776 KB |
Output is correct |
14 |
Correct |
81 ms |
10696 KB |
Output is correct |
15 |
Correct |
153 ms |
14256 KB |
Output is correct |
16 |
Correct |
216 ms |
13948 KB |
Output is correct |
17 |
Correct |
153 ms |
14496 KB |
Output is correct |
18 |
Correct |
150 ms |
14580 KB |
Output is correct |
19 |
Incorrect |
447 ms |
15940 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |