제출 #1162869

#제출 시각아이디문제언어결과실행 시간메모리
1162869tsengang경주 (Race) (IOI11_race)C++17
0 / 100
10 ms23872 KiB
#include <bits/stdc++.h>
#include "race.h"
using namespace std;
#define ll int
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ertunt return
#define vodka void
vector<pair<int,int>>v[1000006];
ll ans = 1e9;
bool vis[200006];
vodka dfs(ll x,vector<int>q,ll cur,ll k){
    if(vis[x])ertunt;
    vis[x] = 1;
    if(cur == k)ans = min(ans,(ll)q.size());
    while(cur > k){
        cur -= q[0];
        q.erase(q.begin());
    }
    for(auto [z,y] : v[x]){
        vector<int> g = q;
        g.pb(y);
        dfs(z,g,cur+y,k);
    }
}
int best_path(int n,int k,int h[][2],int l[]){
    for(ll i = 0; i < n-1; i++){
        v[h[i][0]].pb({h[i][1],l[i]});
        v[h[i][1]].pb({h[i][0],l[i]});
    }
    vector<int>d;
    for(ll i = 0; i < n; i++){
        if(v[i].size() == 1)d.pb(i);
    }
    for(auto i : d){
        vector<int>f;
        dfs(i,f,0,k);
        fill(vis,vis+n+5,0);
    }
    ertunt ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...