This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "speedrun.h"
#include <bits/stdc++.h>
using namespace std;
void assignHints(int subtask, int n, int a[], int b[]) { /* your solution here */
	vector<int> ord, up(n + 1);
	vector<vector<int>> adj(n + 1);
	for(int i = 1; i < n; i++) {
		adj[a[i]].emplace_back(b[i]);
		adj[a[i]].emplace_back(b[i]);
	}
	auto dfs = [&](auto &&self, int u) -> void {
		ord.emplace_back(u);
		for(const auto &it: adj[u]) if(it != up[u]) {
			up[it] = u;
			self(self, it);
		}
	};
	dfs(dfs, 1);
	setHintLen(20);
	auto setHintUp = [&](int u, int val) -> void {
		for(int i = 0; i < 10; i++) {
			setHint(u, i + 1, val >> i & 1);
		}
	};
	auto setHintNext = [&](int u, int val) -> void {
		for(int i = 0; i < 10; i++) {
			setHint(u, i + 11, val >> i & 1);
		}
	};
	for(int i = 1; i <= n; i++) {
		setHintUp(i, up[i]);
		setHintNext(ord[i - 1], ord[i % n]);
	}
}
void speedrun(int subtask, int n, int u) { /* your solution here */
	auto getHintUp = [&]() -> int {
		int res = 0;
		for(int i = 0; i < 10; i++) {
			res |= getHint(i + 1) << i;
		}
		return res;
	};
	auto getHintNext = [&]() -> int {
		int res = 0;
		for(int i = 0; i < 10; i++) {
			res |= getHint(i + 11) << i;
		}
		return res;
	};
	while(u != 1) {
		u = getHintUp();
		goTo(u);
	}
	do {
		int nxt = getHintNext();
		while(!goTo(nxt)) {
			u = getHintUp();
			goTo(u);
		}
		u = nxt;
	} while(u != 1);
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |