This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "swap.h"
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int ans;
vector<pair<int,int> >vp;
int fromzerotoX[100001];
int n , m;
int closedcircle=1 , issubtask1=1;
vector<int>adj[100001];
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
n=N;
m=M;
for(int i = 0 ; i < V.size() ; i++)
{
adj[V[i]].push_back(U[i]);
adj[U[i]].push_back(V[i]);
fromzerotoX[V[i]]=W[i];
if(U[i]!=0)issubtask1=0;
vp.push_back({W[i], V[i]});
}
ans=*max_element(W.begin() , W.end());
sort(vp.begin() , vp.end());
for(int i = 0 ; i < n ; i++)
{
if(adj[i].size()!=2)
{
closedcircle=0;
break;
}
}
}
int getMinimumFuelCapacity(int X, int Y){
if(!issubtask1)
{
if(closedcircle)
{
return ans;
}
return -1;
}
if(n<4)return -1;
int x=X , y=Y , out=0;
if(x>y)
{
swap(x,y);
}
if(x==0)
{
int c=0;
out=max(out , fromzerotoX[y]);
for(auto u :vp )
{
if(u.second!=y)
{
out=max(out , u.first);
c++;
}
if(c==2)
break;
}
return out;
}
out=max( fromzerotoX[x] , fromzerotoX[y]);
for(auto u :vp )
{
if(u.second!=y&&u.second!=x)
{
out=max(out , u.first);
break;
}
}
return out;
}
Compilation message (stderr)
swap.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
swap.cpp:14:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for(int i = 0 ; i < V.size() ; i++)
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |