Submission #513589

#TimeUsernameProblemLanguageResultExecution timeMemory
513589AlexandruabcdeSpeedrun (RMI21_speedrun)C++14
100 / 100
260 ms908 KiB
#include "speedrun.h" #include <bits/stdc++.h> using namespace std; constexpr int NMAX = 1005; int L; vector <int> G[NMAX]; int last; void SetDad (int Node, int val) { for (int i = 0; i < 10; ++ i ) setHint(Node, i+1, ((val&(1<<i)) != 0)); } int FindDad () { int val = 0; for (int i = 10; i >= 1; -- i ) val = val * 2 + getHint(i); return val; } void SetNextEuler (int Node, int val) { for (int i = 0; i < 10; ++ i ) setHint(Node, i+11, ((val&(1<<i)) != 0)); } int FindNextEuler () { int val = 0; for (int i = 20; i >= 11; -- i ) val = val * 2 + getHint(i); return val; } void Dfs (int Node, int dad = 0) { SetDad(Node, dad); bool first = 1; for (auto it : G[Node]) { if (it == dad) continue; SetNextEuler(last, it); last = it; Dfs(it, Node); } } void assignHints(int subtask, int N, int A[], int B[]) { L = 20; setHintLen(L); for (int i = 1; i < N; ++ i ) { G[A[i]].push_back(B[i]); G[B[i]].push_back(A[i]); } last = 1; Dfs(1); } void GoToRoot (int node) { while (node != 1) { int dad = FindDad(); node = dad; goTo(dad); } } int n; int cnt_viz; void Solve (int node) { cnt_viz++; if (cnt_viz == n) return; int urm = FindNextEuler(); while (!goTo(urm)) { int dad = FindDad(); goTo(dad); } Solve(urm); } void speedrun(int subtask, int N, int start) { GoToRoot(start); n = N; cnt_viz = 0; Solve(1); }

Compilation message (stderr)

speedrun.cpp: In function 'void Dfs(int, int)':
speedrun.cpp:39:10: warning: unused variable 'first' [-Wunused-variable]
   39 |     bool first = 1;
      |          ^~~~~
#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...