#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;
vector<pair<int,int> > g[100005],subtask2;
vector<tuple<int,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(m==n-1&&flag==-1)
{
for(int i=2;i<=n;i++)
{
node=i;
w=g[i][0].Y;
subtask2.pb({w,node});
}
sort(subtask2.begin(),subtask2.end());
}
}
int getMinimumFuelCapacity(int X, int Y)
{
x=X+1;
y=Y+1;
if(type==-1)return -1;
if(m==n-1&&flag==-1)
{
if(x==1||y==1)return -1;
if(n<=3)return -1;
if(x==subtask2[0].Y&&y==subtask2[1].Y||x==subtask2[1].Y&&y==subtask2[0].Y)
{
return subtask2[2].X;
}
return max(g[x][0].Y,g[y][0].Y);
}
}
Compilation message
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:60:28: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
60 | if(x==subtask2[0].Y&&y==subtask2[1].Y||x==subtask2[1].Y&&y==subtask2[0].Y)
| ^
swap.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
66 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2660 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2728 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
45 ms |
10392 KB |
Output is correct |
10 |
Correct |
59 ms |
11524 KB |
Output is correct |
11 |
Correct |
54 ms |
11472 KB |
Output is correct |
12 |
Correct |
57 ms |
11812 KB |
Output is correct |
13 |
Correct |
63 ms |
11780 KB |
Output is correct |
14 |
Correct |
50 ms |
10628 KB |
Output is correct |
15 |
Correct |
106 ms |
15620 KB |
Output is correct |
16 |
Correct |
117 ms |
15368 KB |
Output is correct |
17 |
Correct |
118 ms |
15908 KB |
Output is correct |
18 |
Correct |
129 ms |
15884 KB |
Output is correct |
19 |
Incorrect |
56 ms |
8044 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Incorrect |
125 ms |
17920 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2660 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2728 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Runtime error |
4 ms |
5140 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
5140 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2660 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2728 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
45 ms |
10392 KB |
Output is correct |
10 |
Correct |
59 ms |
11524 KB |
Output is correct |
11 |
Correct |
54 ms |
11472 KB |
Output is correct |
12 |
Correct |
57 ms |
11812 KB |
Output is correct |
13 |
Correct |
63 ms |
11780 KB |
Output is correct |
14 |
Correct |
50 ms |
10628 KB |
Output is correct |
15 |
Correct |
106 ms |
15620 KB |
Output is correct |
16 |
Correct |
117 ms |
15368 KB |
Output is correct |
17 |
Correct |
118 ms |
15908 KB |
Output is correct |
18 |
Correct |
129 ms |
15884 KB |
Output is correct |
19 |
Incorrect |
125 ms |
17920 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
5140 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |