Submission #1024973

#TimeUsernameProblemLanguageResultExecution timeMemory
1024973dostsRace (IOI11_race)C++17
0 / 100
12 ms14680 KiB
#include "race.h" //Dost SEFEROĞLU #include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define ff first #define ss second #define sp << " " << #define vi vector<int> #define all(xx) xx.begin(),xx.end() #define ps(xxx) cout << (xxx) << endl; const int LIM = 2e5+1; vector<pii> edges[LIM]; map<int,int> s[LIM]; int ans = -1; int k; void dfs(int node,int p,int d = 0,int dep = 0) { for (auto it : edges[node]) if (it.ss != p) dfs(it.ss,node,d+it.ff,dep+1); //d[a]+d[b] = K+2D s[node][d] = dep; for (auto it : edges[node]) { if (it.ss == p) continue; if (s[it.ss].size() > s[node].size()) s[it.ss].swap(s[node]); for (auto it : s[it.ss]) { if (s[node].count(k+2*d-it.ff)) { if (ans == -1) ans = it.ss+s[node][k+2*d-it.ff]-2*dep; else ans = min(ans,it.ss+s[node][k+2*d-it.ff])-2*dep; } } for (auto it : s[it.ss]) { if (s[node].count(it.ff)) s[node][it.ff] = min(s[node][it.ff],it.ss); else s[node][it.ff] = it.ss; } } cout << "STUFF" sp node << endl; for (auto it : s[node]) cout << it.ff sp it.ss << endl; } int32_t best_path(int32_t N, int32_t K, int32_t H[][2], int32_t L[]) { k = K; int anss = 0; for (int i=0;i<N-1;i++) { edges[H[i][0]].push_back({L[i],H[i][1]}); edges[H[i][1]].push_back({L[i],H[i][0]}); if (L[i] == K) anss = 1; } if (anss == 1) return 1; dfs(0,0); return 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...