Submission #573048

# Submission time Handle Problem Language Result Execution time Memory
573048 2022-06-05T16:55:04 Z urosk Speedrun (RMI21_speedrun) C++14
0 / 100
1 ms 592 KB
#include "speedrun.h"
#include <bits/stdc++.h>
#define ld double
#define ll int
#define llinf 100000000000000000LL // 10^17
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) (ll)(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);

using namespace std;

#define maxn 1005
ll n;
ll in[maxn];
vector<ll> g[maxn];
ll b[maxn];
ll nxt[maxn];
ll p[maxn];
ll ti = 1;
void dfs(ll u,ll par){
    in[u] = ti++;
    b[ti-1] = u;
    p[u] = par;
    for(ll s : g[u]){
        if(s==par) continue;
        dfs(s,u);
    }
}
void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */
    setHintLen(20);
    n = N;
    for(ll i = 1;i<=n;i++){
        ll x = A[i];
        ll y = B[i];
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1,0);
    for(ll i = 1;i<=n;i++) nxt[i] = b[in[i]+1];
    for(ll i = 1;i<=n;i++){
        for(ll j = 0;j<10;j++) if(p[i]&(1<<j)) setHint(i,j+1,1);
        for(ll j = 0;j<10;j++) if(nxt[i]&(1<<j)) setHint(i,j+11,1);
    }
}
ll getpar(){
    ll y = 0;
    for(ll j = 0;j<10;j++){
        if(getHint(j+1)) y+=(1<<j);
    }
    return y;
}
ll getnxt(){
    ll y = 0;
    for(ll j = 0;j<10;j++){
        if(getHint(j+11)) y+=(1<<j);
    }
    return y;
}
void speedrun(int subtask, int N, int start) { /* your solution here */
    ll x = start;
    ll n = N;
    ll y = x;
    while(y!=1){
        y = getpar();
        goTo(y);
        x = y;
    }
    y = getnxt();
    ll visi = 1;
    while(x!=0){
        if(goTo(y)){
            x = y;
            y = getnxt();
            visi++;
        }else{
            x = getpar();
            goTo(x);
        }
    }
    return;
}
/*
5
1 2
2 3
3 4
3 5
3
*/

Compilation message

speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:69:8: warning: unused variable 'n' [-Wunused-variable]
   69 |     ll n = N;
      |        ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -