Submission #536958

# Submission time Handle Problem Language Result Execution time Memory
536958 2022-03-14T08:14:13 Z jamezzz Speedrun (RMI21_speedrun) C++17
0 / 100
82 ms 712 KB
#include "speedrun.h"
#include <bits/stdc++.h>
using namespace std;

#define pf printf
#define pb push_back

vector<int> AL[1005],pre;
int par[1005],nx[1005];

void dfs(int u,int p){
	par[u]=p;pre.pb(u);
	for(int v:AL[u]){
		if(v!=p)dfs(v,u);
	}
}

void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */
	for(int i=1;i<N;++i)AL[A[i]].pb(B[i]),AL[B[i]].pb(A[i]);
	dfs(1,0);pre.pb(0);
	setHintLen(20);
	for(int i=1;i<=N;++i){
		for(int j=1;j<=10;++j)if(par[i]&(1<<(j-1)))setHint(i,j,1);
		for(int j=11;j<=20;++j)if(pre[i]&(1<<(j-11)))setHint(i,j,1);
	}
}

void speedrun(int subtask, int N, int start) { /* your solution here */
	int cur=start;
	memset(par,-1,sizeof par);
	memset(nx,-1,sizeof nx);
	while(cur!=1){
		if(par[cur]==-1){
			par[cur]=0,nx[cur]=0;
			for(int j=1;j<=10;++j)if(getHint(j))par[cur]+=1<<(j-1);
			for(int j=11;j<=20;++j)if(getHint(j))nx[cur]+=1<<(j-11);
		}
		goTo(par[cur]);cur=par[cur];
	}
	while(true){//Euler tour
		if(par[cur]==-1){
			par[cur]=0,nx[cur]=0;
			for(int j=1;j<=10;++j)if(getHint(j))par[cur]+=1<<(j-1);
			for(int j=11;j<=20;++j)if(getHint(j))nx[cur]+=1<<(j-11);
		}
		if(nx[cur]==0)break;
		int to=nx[cur];
		while(!goTo(to)){
			goTo(par[cur]);
			cur=par[cur];
		}
		cur=to;
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 676 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 74 ms 712 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 672 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 700 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 79 ms 696 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -