# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642933 | danikoynov | Speedrun (RMI21_speedrun) | C++14 | 161 ms | 892 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.
/**
* user: koynov-b21
* fname: Daniel Iliev
* lname: Koynov
* task: Speedrun
* score: 100.0
* date: 2021-12-16 11:34:19.470183
*/
#include<bits/stdc++.h>
#include "speedrun.h"
using namespace std;
const int maxn = 1010;
vector < int > g[maxn], ch[maxn];
int deg[maxn], par[maxn], nxt[maxn];
vector < int > trav;
void assignDfs(int v, int p)
{
trav.push_back(v);
for (int i = 0; i < g[v].size(); i ++)
{
int u = g[v][i];
if (u == p)
continue;
par[u] = v;
assignDfs(u, v);
}
}
void assignHints(int subtask, int N, int A[], int B[])
{
setHintLen(20);
for (int i = 1; i < N; i ++)
{
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
deg[A[i]] ++;
deg[B[i]] ++;
}
assignDfs(1, -1);
for (int i = 0; i < trav.size() - 1; i ++)
{
nxt[trav[i]] = trav[i + 1];
}
for (int i = 1; i <= N; i ++)
{
for (int j = 0; j < 10; j ++)
{
if ((par[i] & (1 << j)) > 0)
setHint(i, j + 1, true);
}
for (int j = 0; j < 10; j ++)
{
if ((nxt[i] & (1 << j)) > 0)
setHint(i, j + 11, true);
}
}
}
void getParent(int ver)
{
par[ver] = 0;
for (int bit = 0; bit < 10; bit ++)
if (getHint(bit + 1))
par[ver] += (1 << bit);
}
void speedrun(int subtask, int N, int start)
{
int l = getLength();
for (int i = 1; i <= N; i ++)
par[i] = 0;
int ver = start;
while(ver != 1)
{
getParent(ver);
goTo(par[ver]);
ver = par[ver];
}
int cnt = 1;
while(cnt < N)
{
int nxtn = 0;
for (int bit = 0; bit < 10; bit ++)
if (getHint(bit + 11))
nxtn += (1 << bit);
getParent(nxtn);
while(!goTo(nxtn))
{
getParent(ver);
goTo(par[ver]);
ver = par[ver];
}
goTo(nxtn);
ver = nxtn;
cnt ++;
}
}
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... |