Submission #412490

#TimeUsernameProblemLanguageResultExecution timeMemory
412490jeqchoRace (IOI11_race)C++17
21 / 100
3060 ms11208 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pair<int,int>> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define pb push_back #define rsz resize #define sz(x) int(x.size()) #define all(x) begin(x), end(x) #define fi first #define se second int const n=2e5+3; vpi adj[n]; int const INF=1e9; // subtask 1,2 int dfs(int now, int par, int w, int k) { if(w > k)return INF; if(w==k)return 0; int mn=INF; trav(chi,adj[now]) { if(chi.fi==par)continue; mn=min(mn,1+dfs(chi.fi,now,w+chi.se,k)); } return mn; } int best_path(int N, int K, int H[][2], int L[]){ F0R(i,N-1) { int u = H[i][0]; int v = H[i][1]; adj[u].pb({v,L[i]}); adj[v].pb({u,L[i]}); } int mn=INF; F0R(i,N) { mn=min(mn,dfs(i,-1,0,K)); } if(mn>=INF)return -1; return mn; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...