# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
335403 | codebuster_10 | 악어의 지하 도시 (IOI11_crocodile) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std ;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define ld long double
#define f(i,a,b) for(int i=a;i<b;++i)
#define endl '\n'
#define debug cout<<"\n========================================\n";
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;
#define PQ priority_queue
#define LB lower_bound
#define UB upper_bound
#define fr first
#define sc second
#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define show(a) {for(auto xyz:a)cout<<xyz<<" ";cout<<endl;}
#define sz(x) (int)(x).size()
const int INF = 1e18 ;
void dfs(int i,int p,vector< vector< array<int,2> > > &g,vector<int> &best){
vector<int> V ;
for(auto [j,w]:g[i]) if(j!=p){
dfs(j,i,g,best) ;
V.push_back(best[j] + w) ;
}
sort(all(V)) ;
best[i] = V[1] ;
}
int travel_plan(int N, int M, int R[][2],int L[], int K,int P[]){
vector< vector< array<int,2> > > g(N) ;
f(i,0,M){
int u = R[i][0], v = R[i][1], w = L[i] ;
g[u].push_back({v, w}) ;
g[v].push_back({u, w}) ;
}
vector<int> best(N,-1) ;
f(i,0,K) best[P[i]] = 0 ;
dfs(0,0,g,best) ;
cout << best[0] ;
}