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;
// typedef long long ll;
int dp[1000001*4]={0};
int n,m,k;
vector<pair<int,int>> adj[1000001*4];
bool blocked[1000001*4]={0};
void dfs(int v, int pV){
if(blocked[v])dp[v]=0;
else{
vector<int> sus(3,1000000001);
for(auto [w,d] : adj[v]){
if(w!=pV){
dfs(w,v);
sus[2]=dp[w]+d;
sort(sus.begin(),sus.end());
}
}
dp[v]=min(1000000001,sus[1]);
}
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
n=N;
m=M;
k=K;
for(int i=0;i<m;i++){
adj[R[i][0]].push_back({R[i][1],L[i]});
adj[R[i][1]].push_back({R[i][0],L[i]});
}
for(int i=0;i<k;i++)blocked[P[i]]=1;
dfs(0,0);
// for(int i=0;i<n;i++)cout << dp[i] << ' ';
// cout << '\n';
return dp[0];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |