# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
349615 | evn | Crocodile's Underground City (IOI11_crocodile) | C++14 | 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>
#include "crocodile.h"
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
typedef long long ll;
typedef pair<int, int> pii;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll dist[1005];
vector<pii> adj[1005];
bool isExit[1005];
ll ans = 1e18;
void dfs(int u, int p){
for(pii e : adj[u]){
int v=e.f;
int w = e.s;
if(v == p)continue;
dist[v] = dist[u] + 1LL * w;
dfs(v, u);
}
vector<ll> children;
for(pii e : adj[u]){
if(e.f != p){
children.pb(dist[e.f]);
}
}
sort(children.begin(), children.end());
if(children.size() >= 2){
ans = min(ans, children[1]);
}
}
int travel_plan(int N, int M, vector<vector<int>> R, vector<int> L, int K, vector<int> P){
for(int i =0; i < R.size(); i++){
adj[R[i][0]].pb({R[i][1], L[i]});
adj[R[i][1]].pb({R[i][0], L[i]});
}
for(int i = 0; i < K; i++){
isExit[P[i]] = true;
}
dfs(0, -1);
return (int)ans;
}
/**
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}**/