#include "swap.h"
//#include "grader.cpp"
#include<bits/stdc++.h>
using namespace std;
const int mx=2e5+10;
typedef long long ll;
int inf=1e9+10;
const int mod=1e9+7;
vector<pair<int,int>>adj[mx];
int ans=-1;
int n,m;
int block[mx];
int arr[mx];
int ok;
vector<pair<int,pair<int,int>>>edges;
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++){
if(U[i]){ok=1;}
arr[V[i]]=W[i];
edges.push_back({W[i],{U[i],V[i]}});
adj[U[i]].push_back({V[i],W[i]});
adj[V[i]].push_back({U[i],W[i]});
}
for(auto it:W){
ans=max(ans,it);
}
for(int i=0;i<N;i++){
if(adj[i].size()!=2){
ans=-1;
}
}
sort(edges.begin(),edges.end());
}
int vis[mx];
int cost1;int targ1;
/*
int dfs(int node,int mx){
vis[node]=1;
for(auto it:adj[node]){
if(it.first==targ1){
int z=max(mx,it.second);
ans=min(z,ans);
}
}
}
*/
int getMinimumFuelCapacity(int X, int Y) {
/*
for(int i=0;i<n;i++){
if(i!=x&&i!=y){
block[i]=1;
targ1=i;
cost1=inf;
dfs(x,0);
}
}*/
int x,y;x=X;y=Y;
if(ok){
return ans;
}
if(x==0||y==0){
if(y==0){
swap(x,y);
}
if(adj[0].size()<3){
return -1;
}else{
ans=arr[y];
int cnt=0;
for(int i=0;i<m;i++){
if(edges[i].second.second==y){
}else if(cnt<2){
ans=max(ans,edges[i].first);
cnt++;
}else{
break;
}
}
return ans;
}
}else{
if(adj[0].size()<3){
return -1;
}else{
ans=arr[x];
ans=max(ans,arr[y]);
for(int i=0;i<m;i++){
if(edges[i].second.second==y||edges[i].second.second==x){
}else {
ans=max(ans,edges[i].first);
break;
}
}
return ans;
}
}}
/*
4 3
0 1 7
0 2 6
0 3 5
1
0 1
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
4940 KB |
Output is correct |
3 |
Correct |
3 ms |
4940 KB |
Output is correct |
4 |
Correct |
3 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
5064 KB |
Output is correct |
6 |
Correct |
4 ms |
4940 KB |
Output is correct |
7 |
Correct |
4 ms |
5068 KB |
Output is correct |
8 |
Correct |
4 ms |
5068 KB |
Output is correct |
9 |
Correct |
56 ms |
10980 KB |
Output is correct |
10 |
Correct |
67 ms |
11776 KB |
Output is correct |
11 |
Correct |
65 ms |
11796 KB |
Output is correct |
12 |
Correct |
68 ms |
12004 KB |
Output is correct |
13 |
Correct |
69 ms |
12056 KB |
Output is correct |
14 |
Correct |
58 ms |
11132 KB |
Output is correct |
15 |
Correct |
161 ms |
13572 KB |
Output is correct |
16 |
Correct |
125 ms |
13372 KB |
Output is correct |
17 |
Correct |
142 ms |
13788 KB |
Output is correct |
18 |
Correct |
130 ms |
13740 KB |
Output is correct |
19 |
Correct |
64 ms |
9540 KB |
Output is correct |
20 |
Correct |
142 ms |
14696 KB |
Output is correct |
21 |
Correct |
138 ms |
14804 KB |
Output is correct |
22 |
Correct |
172 ms |
15152 KB |
Output is correct |
23 |
Correct |
129 ms |
15196 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
4940 KB |
Output is correct |
3 |
Correct |
122 ms |
15356 KB |
Output is correct |
4 |
Correct |
119 ms |
15672 KB |
Output is correct |
5 |
Correct |
127 ms |
15672 KB |
Output is correct |
6 |
Correct |
119 ms |
15544 KB |
Output is correct |
7 |
Correct |
125 ms |
15732 KB |
Output is correct |
8 |
Correct |
120 ms |
15388 KB |
Output is correct |
9 |
Correct |
124 ms |
15532 KB |
Output is correct |
10 |
Correct |
123 ms |
15360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
4940 KB |
Output is correct |
3 |
Correct |
3 ms |
4940 KB |
Output is correct |
4 |
Correct |
3 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
5064 KB |
Output is correct |
6 |
Correct |
4 ms |
4940 KB |
Output is correct |
7 |
Correct |
4 ms |
5068 KB |
Output is correct |
8 |
Correct |
4 ms |
5068 KB |
Output is correct |
9 |
Incorrect |
3 ms |
4940 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4940 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
4940 KB |
Output is correct |
3 |
Correct |
3 ms |
4940 KB |
Output is correct |
4 |
Correct |
3 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
5064 KB |
Output is correct |
6 |
Correct |
4 ms |
4940 KB |
Output is correct |
7 |
Correct |
4 ms |
5068 KB |
Output is correct |
8 |
Correct |
4 ms |
5068 KB |
Output is correct |
9 |
Correct |
56 ms |
10980 KB |
Output is correct |
10 |
Correct |
67 ms |
11776 KB |
Output is correct |
11 |
Correct |
65 ms |
11796 KB |
Output is correct |
12 |
Correct |
68 ms |
12004 KB |
Output is correct |
13 |
Correct |
69 ms |
12056 KB |
Output is correct |
14 |
Correct |
58 ms |
11132 KB |
Output is correct |
15 |
Correct |
161 ms |
13572 KB |
Output is correct |
16 |
Correct |
125 ms |
13372 KB |
Output is correct |
17 |
Correct |
142 ms |
13788 KB |
Output is correct |
18 |
Correct |
130 ms |
13740 KB |
Output is correct |
19 |
Correct |
122 ms |
15356 KB |
Output is correct |
20 |
Correct |
119 ms |
15672 KB |
Output is correct |
21 |
Correct |
127 ms |
15672 KB |
Output is correct |
22 |
Correct |
119 ms |
15544 KB |
Output is correct |
23 |
Correct |
125 ms |
15732 KB |
Output is correct |
24 |
Correct |
120 ms |
15388 KB |
Output is correct |
25 |
Correct |
124 ms |
15532 KB |
Output is correct |
26 |
Correct |
123 ms |
15360 KB |
Output is correct |
27 |
Incorrect |
4 ms |
5068 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4940 KB |
Output isn't correct |