# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
536929 | joelau | Speedrun (RMI21_speedrun) | C++14 | 0 ms | 0 KiB |
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>
void assignHints(int subtask, int N, int A[], int B[]) {
int deg[N+5];
memset(deg,0,sizeof(deg));
for (int i = 1; i < N; ++i) deg[A[i]]++, deg[B[i]]++;
int x = 1;
for (int i = 1; i <= N; ++i) if (deg[i] > deg[x]) x = i;
setHintLen(20);
for (int i = 0; i < 20; ++i) for (int j = 1; j <= N; ++j) if (x & (1<<i)) setHint(j,i+1,1);
}
void speedrun(int subtask, int N, int start) {
int len = getLength();
bitset<1005> visited;
visited[start] = 1;
int x = 0;
for (int i = 0; i < 20; ++i) if (getHint(i+1)) x |= (1<<i);
if (start != x) goTo(x), visited[x] = 1;
for (int i = 1; i <= N; ++i) if (!visited[i]) goTo(i), goTo(x);
}