# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642519 | Tenis0206 | 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 <bits/stdc++.h>
#include "speedrun.h"
using namespace std;
int l[1005],t[1005];
vector<int> G[1005];
int poz = 0;
void dfs(int nod, int dad = 0)
{
l[++poz] = nod;
for(auto it : G[nod])
{
if(it==dad)
{
continue;
}
t[it] = nod;
dfs(it,nod);
}
}
void setDad(int nod, int dad)
{
for(int b=0;b<10;b++)
{
bool val = ((dad & (1<<b)) != 0);
setHint(nod,b+1,val);
}
}
void setNext(int nod, int next)
{
for(int b=0;b<10;b++)
{
bool val = ((next & (1<<b)) != 0);
setHint(nod,b+11,val);
}
}
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]);
}
dfs(1);
for(int i=1;i<=n;i++)
{
setDad(l[i],t[i]);
setNext(l[i],l[i+1]);
}
}
int getDad()
{
int rez = 0;
for(int b=0;b<10;b++)
{
int val = getHint(b + 1);
rez += val * (1<<b);
}
return rez;
}
int getNext()
{
int rez = 0;
for(int b=0;b<10;b++)
{
int val = getHint(b + 11);
rez += val * (1<<b);
}
return rez;
}
void speedrun(int subtask, int n, int start)
{
getLength();
int nod = start;
while(nod!=1)
{
int dad = getDad();
goTo(dad);
nod = dad;
}
for(int i=1;i<n;i++)
{
int next = getNext();
bool ok = goTo(next);
while(!ok)
{
goTo(dad);
ok = goTo(next);
}
}
}