#include<bits/stdc++.h>
#include "speedrun.h"
using namespace std;
const int NN=1e3;
const int L=20;
vector<int> e[NN+10];
vector<int> pre,par;
void encode(int x,int c1,int c2)
{
int c=(c1<<10)+c2;
for(int i=1;i<=20;i++)
{
setHint(x,i,c%2);
c/=2;
}
return;
}
void dfs(int x,int p)
{
pre.push_back(x);
par.push_back(p);
for(auto v:e[x])
{
if(v!=p)
dfs(v,x);
}
return;
}
void assignHints(int subtask, int N, int A[], int B[])
{
setHintLen(L);
for(int i=1;i<N;i++)
{
e[A[i]].push_back(B[i]);
e[B[i]].push_back(A[i]);
}
dfs(1,0);
pre.push_back(pre[0]);
for(int i=0;i<N;i++)
encode(pre[i],pre[i+1],par[i]);
return;
}
pair<int,int> decode(int x)
{
int ans=0;
for(int i=20;i>=1;i--)
ans=2*ans+getHint(i);
return {(ans>>10),ans%(1<<10)};
}
void speedrun(int subtask, int N, int start)
{
int x=start;
while(x!=1)
{
x=decode(x).second;
goTo(x);
}
for(int i=1;i<=N;i++)
{
int y=decode(x).first;
while(!goTo(y))
{
x=decode(x).second;
goTo(x);
}
}
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
138 ms |
760 KB |
Output is correct |
2 |
Correct |
120 ms |
672 KB |
Output is correct |
3 |
Correct |
185 ms |
708 KB |
Output is correct |
4 |
Correct |
185 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
187 ms |
672 KB |
Output is correct |
2 |
Correct |
175 ms |
672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
165 ms |
672 KB |
Output is correct |
2 |
Correct |
136 ms |
712 KB |
Output is correct |
3 |
Correct |
166 ms |
712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
191 ms |
700 KB |
Output is correct |
2 |
Correct |
173 ms |
820 KB |
Output is correct |
3 |
Correct |
166 ms |
720 KB |
Output is correct |
4 |
Correct |
177 ms |
712 KB |
Output is correct |
5 |
Correct |
183 ms |
736 KB |
Output is correct |
6 |
Correct |
148 ms |
708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
152 ms |
844 KB |
Output is correct |
2 |
Correct |
160 ms |
708 KB |
Output is correct |
3 |
Correct |
138 ms |
748 KB |
Output is correct |
4 |
Correct |
197 ms |
720 KB |
Output is correct |
5 |
Correct |
183 ms |
836 KB |
Output is correct |
6 |
Correct |
91 ms |
820 KB |
Output is correct |
7 |
Correct |
160 ms |
672 KB |
Output is correct |