#include<bits/stdc++.h>
using namespace std;
#include "swap.h"
#define X first
#define Y second
#define pb push_back
#include <vector>
int n,m,dg[100005],u_i,v_i,w_i,x,y,type=-1,flag=-1;
int node,w,deter=2;
vector<pair<int,int> > g[100005];
vector<pair<int,pair<int,int> > > v;
void init(int N, int M,
std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
n=N;
m=M;
for(int i=0;i<m;i++)
{
u_i=U[i]+1;
v_i=V[i]+1;
w_i=W[i];
g[u_i].pb({v_i,w_i});
g[v_i].pb({u_i,w_i});
++dg[u_i];
++dg[v_i];
v.push_back({w_i,{u_i,v_i}});
if(u_i!=1)flag=0;
}
sort(v.begin(),v.end());
for(int i=1;i<=n;i++)
{
if(dg[i]>2)
{
type=0;
}
}
if(type==-1)
{
deter=0;
for(int i=1;i<=n;i++)if(dg[i]!=2)deter=-1;
}
}
int getMinimumFuelCapacity(int X, int Y)
{
x=X+1;
y=Y+1;
if(type==-1)
{
if(deter==0)return v[v.size()-1].X;
return -1;
}
if(m==n-1&&flag==-1)
{
if(m<=2)return -1;
if(x==1)
{
if(g[y][0].Y>v[2].X)return g[y][0].Y;
return v[2].X;
}
if(x==v[0].Y.Y&&y==v[1].Y.Y||x==v[1].Y.Y&&y==v[0].Y.Y)return v[2].X;
return max(g[x][0].Y,g[y][0].Y);
}
}
Compilation message
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:63:23: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
63 | if(x==v[0].Y.Y&&y==v[1].Y.Y||x==v[1].Y.Y&&y==v[0].Y.Y)return v[2].X;
| ^
swap.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
66 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
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 |
3 ms |
2644 KB |
Output is correct |
9 |
Correct |
64 ms |
8628 KB |
Output is correct |
10 |
Correct |
63 ms |
9480 KB |
Output is correct |
11 |
Correct |
55 ms |
9468 KB |
Output is correct |
12 |
Correct |
60 ms |
9656 KB |
Output is correct |
13 |
Correct |
55 ms |
9620 KB |
Output is correct |
14 |
Correct |
50 ms |
8752 KB |
Output is correct |
15 |
Correct |
122 ms |
11168 KB |
Output is correct |
16 |
Correct |
107 ms |
11056 KB |
Output is correct |
17 |
Correct |
113 ms |
11440 KB |
Output is correct |
18 |
Correct |
118 ms |
11436 KB |
Output is correct |
19 |
Correct |
61 ms |
7168 KB |
Output is correct |
20 |
Correct |
106 ms |
12348 KB |
Output is correct |
21 |
Correct |
109 ms |
12420 KB |
Output is correct |
22 |
Correct |
124 ms |
12844 KB |
Output is correct |
23 |
Correct |
112 ms |
12840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
110 ms |
13008 KB |
Output is correct |
4 |
Correct |
108 ms |
17140 KB |
Output is correct |
5 |
Correct |
115 ms |
17324 KB |
Output is correct |
6 |
Correct |
143 ms |
17024 KB |
Output is correct |
7 |
Correct |
130 ms |
17268 KB |
Output is correct |
8 |
Correct |
112 ms |
16868 KB |
Output is correct |
9 |
Correct |
103 ms |
17084 KB |
Output is correct |
10 |
Correct |
102 ms |
16896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
3 ms |
2644 KB |
Output is correct |
9 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
3 ms |
2644 KB |
Output is correct |
9 |
Correct |
64 ms |
8628 KB |
Output is correct |
10 |
Correct |
63 ms |
9480 KB |
Output is correct |
11 |
Correct |
55 ms |
9468 KB |
Output is correct |
12 |
Correct |
60 ms |
9656 KB |
Output is correct |
13 |
Correct |
55 ms |
9620 KB |
Output is correct |
14 |
Correct |
50 ms |
8752 KB |
Output is correct |
15 |
Correct |
122 ms |
11168 KB |
Output is correct |
16 |
Correct |
107 ms |
11056 KB |
Output is correct |
17 |
Correct |
113 ms |
11440 KB |
Output is correct |
18 |
Correct |
118 ms |
11436 KB |
Output is correct |
19 |
Correct |
110 ms |
13008 KB |
Output is correct |
20 |
Correct |
108 ms |
17140 KB |
Output is correct |
21 |
Correct |
115 ms |
17324 KB |
Output is correct |
22 |
Correct |
143 ms |
17024 KB |
Output is correct |
23 |
Correct |
130 ms |
17268 KB |
Output is correct |
24 |
Correct |
112 ms |
16868 KB |
Output is correct |
25 |
Correct |
103 ms |
17084 KB |
Output is correct |
26 |
Correct |
102 ms |
16896 KB |
Output is correct |
27 |
Incorrect |
3 ms |
2644 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |