# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1105124 | SteveBro | Race (IOI11_race) | C++17 | 0 ms | 0 KiB |
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 <bits/stdc++.h>
using namespace std;
int mat[200001][2],v[200001],vc[1000001],p;
bool ok[200001];
vector < pair<int,int> > g[200001];
void divide(int nod)
{
int nr=0;
for(auto x : g[nod])
if(!ok[x])
nr++;
if(!nr)
return;
}
int best_path(int n,int k,int h[200001][2],int l[200001])
{
int rez=-1,i;
for(i=1;i<=n;i++)
{
g[h[i][0]].push_back(make_pair(h[i][1],l[i]));
g[h[i][1]].push_back(make_pair(h[i][0],l[i]));
}
p=k;
divide(1);
return rez;
}
int main()
{
int n,i,k;
cin>>n>>k;
for(i=1;i<=n;i++)
{
cin>>mat[i][0]>>mat[i][1];
}
for(i=1;i<=n;i++)
cin>>v[i];
cout<<best_path(n,k,mat,v);
return 0;
}