Submission #536877

# Submission time Handle Problem Language Result Execution time Memory
536877 2022-03-14T06:34:24 Z jamezzz Speedrun (RMI21_speedrun) C++17
60 / 100
104 ms 856 KB
#include "speedrun.h"
#include <bits/stdc++.h>
using namespace std;

#define pf printf
#define pb push_back

void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */
	if(subtask==1){
		setHintLen(N);
		for(int i=1;i<N;++i){
			setHint(A[i],B[i],1);
			setHint(B[i],A[i],1);
		}
	}
	if(subtask==2){
		setHintLen(20);
		vector<int> cnt(N+1,0);
		for(int i=1;i<N;++i)++cnt[A[i]],++cnt[B[i]];
		int mx=1;
		for(int i=1;i<=N;++i)if(cnt[i]>cnt[mx])mx=i;
		for(int j=1;j<=20;++j){
			for(int i=1;i<=N;++i){
				if(mx&(1<<(j-1))){
					setHint(i,j,1);
				}
			}
		}
	}
	if(subtask==3){
		setHintLen(20);
		vector<vector<int>> AL(N+1);
		for(int i=1;i<N;++i){
			AL[A[i]].pb(B[i]);
			AL[B[i]].pb(A[i]);
		}
		for(int i=1;i<=N;++i){
			if(AL[i].size()==1)AL[i].pb(0);
		}
		for(int i=1;i<=N;++i){
			for(int j=1;j<=10;++j){
				if(AL[i][0]&(1<<(j-1)))setHint(i,j,1);
			}
			for(int j=11;j<=20;++j){
				if(AL[i][1]&(1<<(j-11)))setHint(i,j,1);
			}
		}
	}
	if(subtask==4){
		setHintLen(316);
		for(int i=1;i<N;++i){
			setHint(A[i],B[i]%316+1,1);
			setHint(B[i],A[i]%316+1,1);
		}
	}
}

void speedrun(int subtask, int N, int start) { /* your solution here */
	if(subtask==1){
		vector<int> cur(N+1,1),p(N+1,-1);
		int pos=start;
		while(true){
			while(cur[pos]!=N+1&&(getHint(cur[pos])==0||cur[pos]==p[pos]))++cur[pos];
			if(cur[pos]==N+1){
				if(p[pos]==-1)break;
				else goTo(p[pos]),pos=p[pos];
			}
			else{
				goTo(cur[pos]);
				p[cur[pos]]=pos;
				pos=cur[pos]++;
			}
		}
	}
	if(subtask==2){
		int cur=1,mid=0,pos=start;
		for(int i=1;i<=20;++i){
			if(getHint(i))mid+=1<<(i-1);
		}
		while(true){
			if(pos!=mid)goTo(mid),pos=mid;
			else{
				if(cur==N+1)break;
				if(cur==mid)++cur;
				goTo(cur);
				pos=cur++;
			}
		}
	}
	if(subtask==3){
		vector<vector<int>> AL(N+1);
		vector<int> p(N+1,-1);
		for(int i=1;i<=N;++i){
			int x=0;
			
		}
		int pos=start;
		while(true){
			if(AL[pos].empty()){
				int x=0;
				for(int j=1;j<=10;++j)if(getHint(j))x+=1<<(j-1);
				if(x!=0)AL[pos].pb(x);
				x=0;
				for(int j=11;j<=20;++j)if(getHint(j))x+=1<<(j-11);
				if(x!=0)AL[pos].pb(x);
			}
			int to=-1;
			for(int i:AL[pos]){
				if(p[i]==-1&&i!=start){
					to=i;
					break;
				}
			}
			if(to==-1){
				if(p[pos]==-1)break;
				else goTo(p[pos]),pos=p[pos];
			}
			else{
				goTo(to),p[to]=pos,pos=to;
			}
		}
	}
	if(subtask==4){
		vector<int> cur(N+1,1),p(N+1,-1);
		int pos=start;
		while(true){
			while(cur[pos]!=N+1&&(getHint(cur[pos]%316+1)==0||cur[pos]==p[pos]))++cur[pos];
			if(cur[pos]==N+1){
				if(p[pos]==-1)break;
				else goTo(p[pos]),pos=p[pos];
			}
			else{
				if(goTo(cur[pos])){
					p[cur[pos]]=pos;
					pos=cur[pos]++;
				}
				else cur[pos]++;
			}
		}
	}
}

Compilation message

speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:94:8: warning: unused variable 'x' [-Wunused-variable]
   94 |    int x=0;
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 47 ms 856 KB Output is correct
2 Correct 47 ms 760 KB Output is correct
3 Correct 44 ms 804 KB Output is correct
4 Correct 50 ms 800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 704 KB Output is correct
2 Correct 46 ms 740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 104 ms 740 KB Output is correct
2 Correct 82 ms 676 KB Output is correct
3 Correct 101 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 728 KB Output is correct
2 Correct 75 ms 704 KB Output is correct
3 Correct 76 ms 684 KB Output is correct
4 Correct 90 ms 724 KB Output is correct
5 Correct 84 ms 796 KB Output is correct
6 Correct 54 ms 756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB setHintLen was never called
2 Halted 0 ms 0 KB -