Submission #538426

# Submission time Handle Problem Language Result Execution time Memory
538426 2022-03-16T19:54:19 Z jamielim Speedrun (RMI21_speedrun) C++14
0 / 100
147 ms 336 KB
#include "speedrun.h"
#include <bits/stdc++.h>
using namespace std;
 
#define pb emplace_back
 
int n;
vector<int> adj[2005];
int par[2005];
vector<int> ord;
int c[2005];
 
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);
	par[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(ord[i]&(1<<(j-11)))setHint(ord[i-1],j,1);
			else setHint(ord[i-1],j,0);
		}
	}
}
 
 
int getParent(){
	int ans=0;
	for(int i=1;i<=10;i++){
		if(getHint(i))ans|=(1<<(i-1));
	}
	return ans;
}
int getNext(){
	int ans=0;
	for(int i=11;i<=20;i++){
		if(getHint(i))ans|=(1<<(i-11));
	}
	return ans;
}
void speedrun(int subtask, int N, int start) {
	int cur=start;
	while(cur!=getParent()&&cur!=1){
		int p=getParent();
		goTo(p);
		cur=p;
	}
	int nxt=getNext();
	while(nxt!=0){
		while(!goTo(nxt)){
			int p=getParent();
			goTo(p);
			cur=p;
		}
		cur=nxt;
		nxt=getNext();
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 147 ms 336 KB Invalid node index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 134 ms 336 KB Invalid node index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 336 KB Invalid node index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 142 ms 336 KB Invalid node index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 141 ms 336 KB Invalid node index for setHint
2 Halted 0 ms 0 KB -