#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
int maxx,minn,maxw;
int n,m,x,y;
vector<int> v[100001],w[100001],num[100001];
pair<int,int> p[100001];
bool sec=1;
struct edge
{
int x,d;
edge(){}
edge(int _x,int _d)
{
x=_x;
d=_d;
}
bool operator<(const edge&e)const
{
return e.d<d;
}
};
void init(int N, int M,std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
minn=N;
n=N;
m=M;
for(int i=0;i<m;i++)
{
if(U[i]!=0)sec=0;
maxw=max(maxw,W[i]);
v[U[i]].push_back(V[i]);
v[V[i]].push_back(U[i]);
w[U[i]].push_back(W[i]);
w[V[i]].push_back(W[i]);
num[U[i]].push_back(i);
num[V[i]].push_back(i);
maxx=max(maxx,(int)v[U[i]].size());
maxx=max(maxx,(int)v[V[i]].size());
p[i]={W[i],V[i]};
}
sort(p,p+m);
for(int i=0;i<n;i++)
{
minn=min(minn,(int)v[i].size());
}
}
int getMinimumFuelCapacity(int X, int Y)
{
x=X;
y=Y;
if(maxx<=2)
{
if(minn==1)return -1;
return maxw;
}
if(sec)
{
int ans=p[0].first;
if(p[0].second==x||p[0].second==y)ans=p[1].first;
if(p[1].second==x||p[1].second==y)ans=p[2].first;
}
}
Compilation message
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:66:13: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
66 | int ans=p[0].first;
| ^~~
swap.cpp:70:1: warning: control reaches end of non-void function [-Wreturn-type]
70 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8028 KB |
Output is correct |
3 |
Correct |
2 ms |
8024 KB |
Output is correct |
4 |
Correct |
2 ms |
8028 KB |
Output is correct |
5 |
Correct |
3 ms |
8028 KB |
Output is correct |
6 |
Correct |
2 ms |
8028 KB |
Output is correct |
7 |
Correct |
2 ms |
8028 KB |
Output is correct |
8 |
Correct |
3 ms |
8028 KB |
Output is correct |
9 |
Correct |
55 ms |
17404 KB |
Output is correct |
10 |
Correct |
72 ms |
19316 KB |
Output is correct |
11 |
Correct |
70 ms |
19192 KB |
Output is correct |
12 |
Correct |
93 ms |
19800 KB |
Output is correct |
13 |
Correct |
77 ms |
19796 KB |
Output is correct |
14 |
Correct |
57 ms |
17492 KB |
Output is correct |
15 |
Correct |
114 ms |
21220 KB |
Output is correct |
16 |
Correct |
116 ms |
20900 KB |
Output is correct |
17 |
Correct |
115 ms |
21692 KB |
Output is correct |
18 |
Correct |
115 ms |
21688 KB |
Output is correct |
19 |
Correct |
46 ms |
13396 KB |
Output is correct |
20 |
Correct |
115 ms |
22480 KB |
Output is correct |
21 |
Correct |
134 ms |
22540 KB |
Output is correct |
22 |
Correct |
124 ms |
22956 KB |
Output is correct |
23 |
Correct |
133 ms |
23228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8028 KB |
Output is correct |
3 |
Incorrect |
94 ms |
22108 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8028 KB |
Output is correct |
3 |
Correct |
2 ms |
8024 KB |
Output is correct |
4 |
Correct |
2 ms |
8028 KB |
Output is correct |
5 |
Correct |
3 ms |
8028 KB |
Output is correct |
6 |
Correct |
2 ms |
8028 KB |
Output is correct |
7 |
Correct |
2 ms |
8028 KB |
Output is correct |
8 |
Correct |
3 ms |
8028 KB |
Output is correct |
9 |
Incorrect |
2 ms |
8028 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
8028 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8028 KB |
Output is correct |
3 |
Correct |
2 ms |
8024 KB |
Output is correct |
4 |
Correct |
2 ms |
8028 KB |
Output is correct |
5 |
Correct |
3 ms |
8028 KB |
Output is correct |
6 |
Correct |
2 ms |
8028 KB |
Output is correct |
7 |
Correct |
2 ms |
8028 KB |
Output is correct |
8 |
Correct |
3 ms |
8028 KB |
Output is correct |
9 |
Correct |
55 ms |
17404 KB |
Output is correct |
10 |
Correct |
72 ms |
19316 KB |
Output is correct |
11 |
Correct |
70 ms |
19192 KB |
Output is correct |
12 |
Correct |
93 ms |
19800 KB |
Output is correct |
13 |
Correct |
77 ms |
19796 KB |
Output is correct |
14 |
Correct |
57 ms |
17492 KB |
Output is correct |
15 |
Correct |
114 ms |
21220 KB |
Output is correct |
16 |
Correct |
116 ms |
20900 KB |
Output is correct |
17 |
Correct |
115 ms |
21692 KB |
Output is correct |
18 |
Correct |
115 ms |
21688 KB |
Output is correct |
19 |
Incorrect |
94 ms |
22108 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
8028 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |