Submission #996975

#TimeUsernameProblemLanguageResultExecution timeMemory
9969753omar_ahmedSpeedrun (RMI21_speedrun)C++17
0 / 100
3546 ms344 KiB
#include "speedrun.h" // #include "grader.cpp" #include <bits/stdc++.h> using namespace std; #define all(a) a.begin(), a.end() #define alr(a) a.rbegin(), a.rend() int n; vector < vector < int >> adj; void dfs(int node, int par) { vector < int > arr; for(auto ch : adj[node]) { arr.push_back(ch); if(ch == par) continue; dfs(ch, node); } vector < int > val(n + 1); for(auto i : arr) val[i] = 1; for(int i = 1 ; i <= n ; i++) { setHint(node, i, val[i]); } } void assignHints(int subtask, int N, int A[], int B[]) { n = N; adj = vector < vector < int >> (n + 2); setHintLen(n); for(int i = 1 ; i < n ; i++) { int u = A[i], v = B[i]; adj[u].push_back(v); adj[v].push_back(u); } dfs(1, 1); } void solve(int node, int par) { for(int i = 1 ; i <= n ; i++) { if(i == par) continue; if(getHint(i) == 1) { goTo(i); // cout << node << " -> " << i << endl; solve(i, node); } } if(par != node) { // cout << node << " -> " << par << endl; goTo(par); } } void speedrun(int subtask, int N, int st) { n = N; solve(st, st); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...