Submission #514549

# Submission time Handle Problem Language Result Execution time Memory
514549 2022-01-18T09:03:07 Z kshitij_sodani Speedrun (RMI21_speedrun) C++14
8 / 100
208 ms 808 KB
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second

#include "speedrun.h"
vector<int> adj[1001];
int co=0;
int ind[1001];
int st[1001];
int par[1001];
void dfs(int no,int par2=0){
	st[no]=co;
	ind[co]=no;
	co++;
	par[no]=par2;
	for(auto j:adj[no]){
		if(j!=par2){
			dfs(j,no);
		}
	}
}
void assignHints(int subtask, int n, int aa[], int bb[]) { /* your solution here */
	for(int i=1;i<n;i++){
		adj[aa[i]].pb(bb[i]);
		adj[bb[i]].pb(aa[i]);
	}
	dfs(1);
	setHintLen(20);
		for(int i=1;i<=n;i++){
			//cout<<par[i]<<":"<<st[i]<<endl;
			for(int k=0;k<10;k++){
				if((1<<k)&par[i]){
					setHint(i,k+1,1);
				}
				else{
					setHint(i,k+1,0);
				}
			}
			for(int k=0;k<10;k++){
				if(i==n){
					continue;
				}
				if((1<<k)&ind[st[i]+1]){
					setHint(i,k+11,1);
				}
				else{
					setHint(i,k+11,0);
				}
			}
		}
	
}	

void speedrun(int subtask, int n, int start) { /* your solution here */

	int cur=start;
	while(cur!=1){
		int cur2=0;
		for(int j=1;j<=10;j++){
			int x=getHint(j);
			if(x==1){
				cur2+=(1<<(j-1));
			}
		}
		cur=cur2;
		goTo(cur);
	}
	for(int i=0;i<n-1;i++){
		int ne=0;
		for(int j=11;j<=20;j++){
			int x=getHint(j);
			if(x==1){
				ne+=(1<<(j-11));
			}
		}
		while(goTo(ne)==false){
			int cur2=0;
			for(int j=1;j<=10;j++){
				int x=getHint(j);
				if(x==1){
					cur2+=(1<<(j-1));
				}
			}
			cur=cur2;
			goTo(cur);
		}
		cur=ne;
	}




}
# Verdict Execution time Memory Grader output
1 Incorrect 196 ms 688 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 173 ms 660 KB Output is correct
2 Correct 192 ms 808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 185 ms 656 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 208 ms 660 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 177 ms 660 KB Invalid node index to goTo
2 Halted 0 ms 0 KB -