Submission #590396

# Submission time Handle Problem Language Result Execution time Memory
590396 2022-07-05T22:13:41 Z perchuts Speedrun (RMI21_speedrun) C++17
100 / 100
285 ms 792 KB
#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 time Memory Grader output
1 Correct 219 ms 672 KB Output is correct
2 Correct 157 ms 672 KB Output is correct
3 Correct 285 ms 712 KB Output is correct
4 Correct 196 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 170 ms 672 KB Output is correct
2 Correct 173 ms 740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 163 ms 724 KB Output is correct
2 Correct 161 ms 672 KB Output is correct
3 Correct 192 ms 672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 182 ms 772 KB Output is correct
2 Correct 169 ms 708 KB Output is correct
3 Correct 158 ms 792 KB Output is correct
4 Correct 241 ms 672 KB Output is correct
5 Correct 168 ms 672 KB Output is correct
6 Correct 97 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 200 ms 732 KB Output is correct
2 Correct 185 ms 672 KB Output is correct
3 Correct 215 ms 704 KB Output is correct
4 Correct 163 ms 792 KB Output is correct
5 Correct 198 ms 672 KB Output is correct
6 Correct 192 ms 712 KB Output is correct
7 Correct 100 ms 792 KB Output is correct