답안 #538404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
538404 2022-03-16T18:51:36 Z jamielim Speedrun (RMI21_speedrun) C++14
0 / 100
160 ms 804 KB
#include "speedrun.h"
#include <bits/stdc++.h>
using namespace std;
 
#define pb emplace_back
 
int n;
vector<int> adj[1005];
int par[1005];
vector<int> ord;
int c[1005];
 
void dfs(int x){
	ord.pb(x);
	for(int i:adj[x]){
		if(par[x]==i)continue;
		par[i]=x;
		dfs(i);
	}
}
 
void assignHints(int subtask, int N, int A[], int B[]) {
	n=N;
	for(int i=0;i<n-1;i++){
		adj[A[i]].pb(B[i]);
		adj[B[i]].pb(A[i]);
	}
	dfs(1);
	for(int i=0;i<n-1;i++){
		c[ord[i]]=ord[i+1];
	}
	c[ord[n-1]]=1;
	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);
			else setHint(i,j,0);
		}
		for(int j=11;j<=20;j++){
			if(c[i]&(1<<(j-11)))setHint(i,j,1);
			else setHint(i,j,0);
		}
	}
}
 
 
int getParent(){
	int ans=0;
	for(int i=1;i<=10;i++){
		ans+=getHint(i)*(1<<(i-1));
	}
	return ans;
}
int getNext(){
	int ans=0;
	for(int i=11;i<=20;i++){
		ans+=getHint(i)*(1<<(i-11));
	}
	return ans;
}
void speedrun(int subtask, int N, int start) {
	memset(par,0,sizeof(par));
	memset(c,0,sizeof(c));
	int cur=start;
	while(cur!=1){
		par[cur]=getParent();
		c[cur]=getNext();
		goTo(par[cur]);
		cur=par[cur];
	}
	par[cur]=getParent();
	c[cur]=getNext();
	for(int i=1;i<n;i++){
		int nxt=c[cur];
		while(!goTo(nxt)){
			goTo(par[cur]);
			cur=par[cur];
		}
		// reached the next thing in the order
		cur=nxt;
		par[cur]=getParent();
		c[cur]=getNext();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 100 ms 672 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 150 ms 676 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 160 ms 712 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 148 ms 804 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 141 ms 692 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -