Submission #590394

# Submission time Handle Problem Language Result Execution time Memory
590394 2022-07-05T22:12:43 Z perchuts Speedrun (RMI21_speedrun) C++17
0 / 100
185 ms 656 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=0;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);
        assert(me!=0);
        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 Runtime error 169 ms 644 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 185 ms 648 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 109 ms 656 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 104 ms 648 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 157 ms 644 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -