제출 #590396

#제출 시각아이디문제언어결과실행 시간메모리
590396perchutsSpeedrun (RMI21_speedrun)C++17
100 / 100
285 ms792 KiB
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define sz(x) (int) x.size() #define endl '\n' #define pb push_back #define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #include "speedrun.h" using namespace std; using ll = long long; using ull = unsigned long long; using ii = pair<int,int>; using iii = tuple<int,int,int>; const int inf = 2e9+1; const int mod = 1e9+7; const int maxn = 1002; template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; } template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; } vector<int>g[maxn]; int ordem[maxn], par[maxn], t = 1; void dfs(int u,int p){ ordem[t++] = u, par[u] = p; for(auto v:g[u]){ if(v==p)continue; dfs(v,u); } } void assignHints (int subtask , int n, int a[], int b[]){ setHintLen(20); for(int i=1;i<=n-1;++i){ g[a[i]].pb(b[i]), g[b[i]].pb(a[i]); } dfs(1,1); for(int i=1;i<=n;++i){ int me = ordem[i], mask = ordem[i+1]|(par[me]<<10); for(int j=0;j<20;++j){ setHint(me,j+1,(mask>>j)&1); } } } int dica(){ int hint = 0; for(int i=0;i<20;++i)hint |= (getHint(i+1)<<i); return hint; } void speedrun(int subtask , int N, int start){ int cur = start, mask = ((1<<10)-1); while(cur!=1)cur = (dica()>>10), goTo(cur); stack<int>st; st.push(1); for(int i=1;i<N;++i){ int prox = dica()&mask; while(goTo(prox)==0){ st.pop(); goTo(st.top()); } st.push(prox); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...