답안 #536960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
536960 2022-03-14T08:15:21 Z jamezzz Speedrun (RMI21_speedrun) C++17
0 / 100
91 ms 988 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)){
			assert(par[cur]!=0);
			goTo(par[cur]);
			cur=par[cur];
		}
		cur=to;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 89 ms 988 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 91 ms 740 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 85 ms 928 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 55 ms 928 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 65 ms 928 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -