# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1105124 | SteveBro | 경주 (Race) (IOI11_race) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}