답안 #536878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
536878 2022-03-14T06:34:45 Z errorgorn Speedrun (RMI21_speedrun) C++17
100 / 100
192 ms 840 KB
#include "speedrun.h"

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound

#define rep(x,s,e) for (auto x=(s)-((s)>(e));x!=(e)-((s)>(e));(s)<(e)?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
vector<int> al[1005];
int nxt[1005];

int pp=0;
void dfs(int i,int p){
	int temp=p;
	rep(x,0,10){
		setHint(i,10+x+1,temp&1);
		temp>>=1;
	}
	
	nxt[pp]=i;
	pp=i;
	
	for (auto it:al[i]){
		if (it==p) continue;
		
		dfs(it,i);
	}
}

void assignHints(signed subtask, signed N, signed A[], signed B[]) {
	n=N;
	
	rep(x,1,n){
		al[A[x]].pub(B[x]);
		al[B[x]].pub(A[x]);
	}
	
	setHintLen(20);
	
	dfs(1,0);
	
	rep(x,1,n+1){
		int temp=nxt[x];
		rep(y,0,10){
			setHint(x,y+1,temp&1);
			temp>>=1;
		}
	}
}

int getP(){
	int res=0;
	rep(x,20,10) res=res<<1|getHint(x+1);
	return res;
}

int getN(){
	int res=0;
	rep(x,10,0) res=res<<1|getHint(x+1);
	return res;
}

void speedrun(signed subtask, signed N, signed curr) { 
	n=N;
	
	while (curr!=1){
		int temp=getP();
		goTo(temp);
		curr=temp;
	}
	
	vector<int> stk={curr};
	
	rep(x,1,n){
		int temp=getN();
		
		while (!goTo(temp)){
			stk.pob();
			goTo(stk.back());
		}
		stk.pub(temp);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 143 ms 680 KB Output is correct
2 Correct 159 ms 748 KB Output is correct
3 Correct 184 ms 740 KB Output is correct
4 Correct 165 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 188 ms 672 KB Output is correct
2 Correct 173 ms 736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 184 ms 752 KB Output is correct
2 Correct 161 ms 756 KB Output is correct
3 Correct 185 ms 840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 756 KB Output is correct
2 Correct 184 ms 672 KB Output is correct
3 Correct 146 ms 720 KB Output is correct
4 Correct 170 ms 824 KB Output is correct
5 Correct 149 ms 676 KB Output is correct
6 Correct 167 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 161 ms 704 KB Output is correct
2 Correct 192 ms 832 KB Output is correct
3 Correct 161 ms 672 KB Output is correct
4 Correct 179 ms 692 KB Output is correct
5 Correct 146 ms 724 KB Output is correct
6 Correct 180 ms 672 KB Output is correct
7 Correct 145 ms 672 KB Output is correct