# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
736990 | jk410 | Speedrun (RMI21_speedrun) | C++17 | 249 ms | 964 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>
using namespace std;
vector<int> edge[1001];
int dfsOrder[1002];
int dfsIdx;
int par[1001];
void dfs(int v) {
dfsOrder[++dfsIdx] = v;
for (int i : edge[v]) {
if (i == par[v])
continue;
par[i] = v;
dfs(i);
}
}
void assignHints(int subtask, int N, int A[], int B[]) {
for (int i = 1; i < N; i++) {
edge[A[i]].push_back(B[i]);
edge[B[i]].push_back(A[i]);
}
setHintLen(20);
dfs(1);
dfsOrder[N + 1] = 1;
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= 10; j++)
setHint(dfsOrder[i], j, dfsOrder[i + 1] & (1 << j - 1));
for (int j = 11; j <= 20; j++)
setHint(i, j, par[i] & (1 << j - 11));
}
}
int getNxt() {
int ret = 0;
for (int i = 1; i <= 10; i++) {
if (getHint(i))
ret |= (1 << i - 1);
}
return ret;
}
int getPar() {
int ret = 0;
for (int i = 11; i <= 20; i++) {
if (getHint(i))
ret |= (1 << i - 11);
}
return ret;
}
void speedrun(int subtask, int N, int start) {
for (int cnt = 1, cur = start; cnt < N; cnt++) {
int nxt = getNxt();
if (goTo(nxt)) {
cur = nxt;
continue;
}
while (1) {
if (cur == nxt)
break;
int par = getPar();
goTo(par);
cur = par;
if (goTo(nxt)) {
cur = nxt;
break;
}
}
}
}
Compilation message (stderr)
# | 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... |