This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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) {
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);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |