답안 #536856

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
536856 2022-03-14T06:11:43 Z errorgorn Speedrun (RMI21_speedrun) C++17
0 / 100
82 ms 540 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,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,temp&1);
			temp>>=1;
		}
	}
}

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

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

void speedrun(signed subtask, signed N, signed curr) { 
	while (curr!=1){
		int temp=getP();
		goTo(temp);
		curr=temp;
	}
	
	vector<int> stk={curr};
	
	rep(x,1,n){
		int temp=getN();
		while (!goTo(temp)){
			goTo(stk.back());
			stk.pob();
		}
		stk.pub(temp);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 69 ms 336 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 77 ms 336 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 80 ms 540 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 72 ms 336 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 82 ms 336 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -