#include "speedrun.h"
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using lint = long long;
using vint = vector<int>;
using pii = pair<int,int>;
const int MAX_N=1010;
int n;
vint edge[MAX_N];
int check[MAX_N];
int cnt=0;
void pushbit(int v,int u,int b)
{
//cout << v << ' ' << u << ' ' << b << '\n';
for(int i=0;i<10;i++)
setHint(v,i+b,u>>i&1);
}
int getbit(int b)
{
int u=0;
for(int i=0;i<10;i++)
u+=getHint(i+b)<<i;
return u;
}
void dfs(int v,int p,int u)
{
pushbit(v,p,10);
int non=1;
for(auto v0 : edge[v])
if(v0!=p)
{
pushbit(v,v0,0);
non=0;
dfs(v0,v,u);
u=v0;
}
if(non)
pushbit(v,u,0);
}
void assignHints(int subtask, int N, int A[], int B[])
{
setHintLen(20);
n=N;
for(int i=1;i<n;i++)
{
int u=A[i],v=B[i];
edge[u].push_back(v);
edge[v].push_back(u);
}
int root=1;
for(int i=1;i<=n;i++)
if(edge[i].size()>edge[root].size())root=i;
dfs(root,0,edge[root].back());
}
void follow(int v,int u)
{
//cout << v << '\n';
if(!check[v])
{
check[v]=1;
cnt++;
if(cnt==n)return;
}
if(u==0)
{
int v0=getbit(0);
if(goTo(v0))
follow(v0,0);
else
{
u=v0;
int p=getbit(10);
goTo(p);
follow(p,u);
}
}
else if(goTo(u))
follow(u,0);
else
{
int p=getbit(10);
goTo(p);
follow(p,u);
}
}
void speedrun(int subtask, int N, int start)
{
n=N;
fill(check,check+n+1,0);
cnt=0;
follow(start,0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Invalid bit index for setHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Invalid bit index for setHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Invalid bit index for setHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Invalid bit index for setHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Invalid bit index for setHint |
2 |
Halted |
0 ms |
0 KB |
- |