#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];
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;
}
};
int conv[100001],a[100001];
bool sec=1;
int t[400001];
void build(int i,int l,int r)
{
if(l==r)
{
t[i]=a[l];
return;
}
int m=(l+r)/2;
build(i*2,l,m);
build(i*2+1,m+1,r);
t[i]=max(t[i*2],t[i*2+1]);
}
int query(int i,int l,int r,int ql,int qr)
{
if(ql>qr)return 0;
if(ql<=l&&r<=qr)return t[i];
int m=(l+r)/2;
return max(query(i*2,l,m,ql,min(qr,m)),query(i*2+1,m+1,r,max(m+1,ql),qr));
}
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());
}
for(int i=0;i<n;i++)
{
minn=min(minn,(int)v[i].size());
}
//cout<<maxx<<" "<<minn<<endl;
/*if(maxx<=2)
{
int ver=0;
int cnt=1;
do
{
conv[ver]=cnt;
if(conv[v[ver][0]])ver=v[ver][1],a[cnt]=w[ver][1];
else ver=v[ver][0],a[cnt]=w[ver][0];
if(cnt==n)
{
if(v[ver][0]==0)a[cnt]=w[ver][0];
else a[cnt]=w[ver][1];
}
cnt++;
}while(cnt<=n);
//for(int i=0;i<n;i++)
// cout<<conv[i]<<endl;
build(1,1,n);
}*/
}
int getMinimumFuelCapacity(int X, int Y)
{
x=X;
y=Y;
if(maxx<=2)
{
if(minn==1)return -1;
return maxw;
}
}
Compilation message
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:110:1: warning: control reaches end of non-void function [-Wreturn-type]
110 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
2 ms |
7512 KB |
Output is correct |
3 |
Correct |
2 ms |
7768 KB |
Output is correct |
4 |
Correct |
2 ms |
7516 KB |
Output is correct |
5 |
Correct |
2 ms |
7516 KB |
Output is correct |
6 |
Correct |
2 ms |
7516 KB |
Output is correct |
7 |
Correct |
3 ms |
7768 KB |
Output is correct |
8 |
Correct |
2 ms |
7516 KB |
Output is correct |
9 |
Correct |
45 ms |
16724 KB |
Output is correct |
10 |
Correct |
59 ms |
18772 KB |
Output is correct |
11 |
Correct |
60 ms |
18512 KB |
Output is correct |
12 |
Correct |
65 ms |
19244 KB |
Output is correct |
13 |
Correct |
66 ms |
19316 KB |
Output is correct |
14 |
Correct |
49 ms |
16720 KB |
Output is correct |
15 |
Correct |
108 ms |
20700 KB |
Output is correct |
16 |
Correct |
118 ms |
20228 KB |
Output is correct |
17 |
Correct |
111 ms |
20920 KB |
Output is correct |
18 |
Correct |
108 ms |
20936 KB |
Output is correct |
19 |
Correct |
45 ms |
12788 KB |
Output is correct |
20 |
Correct |
118 ms |
21888 KB |
Output is correct |
21 |
Correct |
104 ms |
21692 KB |
Output is correct |
22 |
Correct |
122 ms |
22456 KB |
Output is correct |
23 |
Correct |
109 ms |
22388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
2 ms |
7512 KB |
Output is correct |
3 |
Incorrect |
87 ms |
21340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
2 ms |
7512 KB |
Output is correct |
3 |
Correct |
2 ms |
7768 KB |
Output is correct |
4 |
Correct |
2 ms |
7516 KB |
Output is correct |
5 |
Correct |
2 ms |
7516 KB |
Output is correct |
6 |
Correct |
2 ms |
7516 KB |
Output is correct |
7 |
Correct |
3 ms |
7768 KB |
Output is correct |
8 |
Correct |
2 ms |
7516 KB |
Output is correct |
9 |
Incorrect |
2 ms |
7516 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
7516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
2 ms |
7512 KB |
Output is correct |
3 |
Correct |
2 ms |
7768 KB |
Output is correct |
4 |
Correct |
2 ms |
7516 KB |
Output is correct |
5 |
Correct |
2 ms |
7516 KB |
Output is correct |
6 |
Correct |
2 ms |
7516 KB |
Output is correct |
7 |
Correct |
3 ms |
7768 KB |
Output is correct |
8 |
Correct |
2 ms |
7516 KB |
Output is correct |
9 |
Correct |
45 ms |
16724 KB |
Output is correct |
10 |
Correct |
59 ms |
18772 KB |
Output is correct |
11 |
Correct |
60 ms |
18512 KB |
Output is correct |
12 |
Correct |
65 ms |
19244 KB |
Output is correct |
13 |
Correct |
66 ms |
19316 KB |
Output is correct |
14 |
Correct |
49 ms |
16720 KB |
Output is correct |
15 |
Correct |
108 ms |
20700 KB |
Output is correct |
16 |
Correct |
118 ms |
20228 KB |
Output is correct |
17 |
Correct |
111 ms |
20920 KB |
Output is correct |
18 |
Correct |
108 ms |
20936 KB |
Output is correct |
19 |
Incorrect |
87 ms |
21340 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
7516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |