Submission #567464

#TimeUsernameProblemLanguageResultExecution timeMemory
567464losmi247Crocodile's Underground City (IOI11_crocodile)C++14
46 / 100
130 ms262144 KiB
#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); if(svi.size() == 1){ dp1[x] = 1e15; return; } 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[][2],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 grane[10*N][2],tezine[10*N],izlazi[N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int br1,br2,br3; cin >> br1 >> br2 >> br3; for(int i = 0; i < br2; i++){ cin >> grane[i][0] >> grane[i][1] >> tezine[i]; } for(int i = 0; i < br3; i++) cin >> izlazi[i]; cout << travel_plan(br1,br2,grane,tezine,br3,izlazi) << endl; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...