#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(n<=3) return -1;
if(X==0 || Y==0){
if(Y==0) swap(X,Y);
st.erase({v[Y][0].ss,Y});
mx=v[Y][0].ss;
mx=max(mx,(*(++st.begin())).ss);
st.insert({v[Y][0].ss,Y});
return mx;
}
else{
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 |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
3 ms |
2644 KB |
Output is correct |
5 |
Correct |
3 ms |
2664 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2716 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
77 ms |
10572 KB |
Output is correct |
10 |
Correct |
110 ms |
12412 KB |
Output is correct |
11 |
Correct |
100 ms |
12164 KB |
Output is correct |
12 |
Correct |
108 ms |
12708 KB |
Output is correct |
13 |
Correct |
95 ms |
12740 KB |
Output is correct |
14 |
Correct |
105 ms |
10704 KB |
Output is correct |
15 |
Correct |
146 ms |
14280 KB |
Output is correct |
16 |
Correct |
151 ms |
13948 KB |
Output is correct |
17 |
Correct |
156 ms |
14560 KB |
Output is correct |
18 |
Correct |
154 ms |
14516 KB |
Output is correct |
19 |
Correct |
50 ms |
7684 KB |
Output is correct |
20 |
Correct |
156 ms |
15364 KB |
Output is correct |
21 |
Correct |
140 ms |
15344 KB |
Output is correct |
22 |
Correct |
158 ms |
15996 KB |
Output is correct |
23 |
Correct |
143 ms |
15924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Incorrect |
434 ms |
15944 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
3 ms |
2644 KB |
Output is correct |
5 |
Correct |
3 ms |
2664 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2716 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 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 |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
3 ms |
2644 KB |
Output is correct |
5 |
Correct |
3 ms |
2664 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2716 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
77 ms |
10572 KB |
Output is correct |
10 |
Correct |
110 ms |
12412 KB |
Output is correct |
11 |
Correct |
100 ms |
12164 KB |
Output is correct |
12 |
Correct |
108 ms |
12708 KB |
Output is correct |
13 |
Correct |
95 ms |
12740 KB |
Output is correct |
14 |
Correct |
105 ms |
10704 KB |
Output is correct |
15 |
Correct |
146 ms |
14280 KB |
Output is correct |
16 |
Correct |
151 ms |
13948 KB |
Output is correct |
17 |
Correct |
156 ms |
14560 KB |
Output is correct |
18 |
Correct |
154 ms |
14516 KB |
Output is correct |
19 |
Incorrect |
434 ms |
15944 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 |
- |