Submission #1009784

# Submission time Handle Problem Language Result Execution time Memory
1009784 2024-06-28T04:29:06 Z Mardonbekhazratov Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
1 ms 4440 KB
#include "crocodile.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;

vector<bool>is;
vector<vector<pair<int,int>>>v;

vector<ll>dfs(int x,ll d = 0,int p=-1){
    if(is[x]) return {d};
    vector<ll>a;
    for(auto [z,w]:v[x]){
        if(z!=p){
            vector<ll>b=dfs(z,d+w,x);
            sort(b.begin(),b.end());
            if(b.size()>1) a.push_back(b[1]);
            else if(b.size()==1) a.push_back(b[0]);
        }
    }
    return a;
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    is.assign(N,false);
    for(int i=0;i<K;i++) is[P[i]]=true;
    v.resize(N);
    for(int i=0;i<M;i++){
        v[R[i][0]].push_back({R[i][1],L[i]});
        v[R[i][1]].push_back({R[i][0],L[i]});
    }
    vector<ll>ans=dfs(0);
    return ans[1];
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -