# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
567460 | losmi247 | 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>
using namespace std;
typedef long long ll;
const int N = 1e5+45;
int n,m,k;
vector <pair<int,ll>> g[N];
bool ex[N];
ll dp1[N];
void dfs(int x,int par){
vector <ll> svi;
for(auto f : g[x]){
int u = f.first;
if(u == par) continue;
ll w = f.second;
dfs(u,x);
svi.push_back(dp1[u]+w);
}
if(svi.empty()) return;
assert(svi.size() >= 2);
sort(svi.begin(),svi.end());
dp1[x] = svi[1];
}
int zadrvo(){
dfs(1,0);
return dp1[1];
}
int travel_plan(int br,int M,int **R,int *L,int K,int *P){
n = br;
m = M;
k = K;
for(int i = 0; i < m; i++){
g[R[i][0]+1].push_back({R[i][1]+1,L[i]});
g[R[i][1]+1].push_back({R[i][0]+1,L[i]});
}
for(int i = 0; i < k; i++){
ex[P[i]+1] = 1;
}
return zadrvo();
}
/*int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int br1,br2,br3;
cin >> br1 >> br2 >> br3;
int **grane = new int *[br2];
for(int i = 0; i < br2; i++) grane[i] = new int [2];
int *tezine = new int [br2];
for(int i = 0; i < br2; i++){
cin >> grane[i][0] >> grane[i][1] >> tezine[i];
}
int *izlazi = new int [br3];
for(int i = 0; i < br3; i++) cin >> izlazi[i];
cout << travel_plan(br1,br2,grane,tezine,br3,izlazi) << endl;
for(int i = 0; i < br2; i++) delete[] grane[i];
delete[] grane;
delete[] tezine;
delete[] izlazi;
}*/