Submission #571076

# Submission time Handle Problem Language Result Execution time Memory
571076 2022-06-01T08:20:50 Z Theo830 Speedrun (RMI21_speedrun) C++17
0 / 100
1 ms 464 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define ull unsigned ll
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
#include "speedrun.h"
vector<vll>adj;
ll par[1005];
ll tim = 0;
ll tin[1005] = {0};
ll arr[1005] = {0};
ll Next[1005];
void dfs(ll idx,ll p){
    par[idx] = p;
    tin[idx] = tim;
    arr[tim] = idx;
    tim++;
    for(auto x:adj[idx]){
        if(x != p){
            dfs(x,idx);
        }
    }
}
void assignHints(int subtask, int N, int A[], int B[]){
    setHintLen(20);
    adj.assign(N+5,vll());
    f(i,1,N){
        adj[A[i]].pb(B[i]);
        adj[B[i]].pb(A[i]);
    }
    dfs(1,0);
    f(i,1,N+1){
        Next[i] = arr[tin[i] + 1];
    }
    f(i,1,N+1){
        f(j,0,10){
            if(par[i] & (1LL<<j)){
                setHint(i,j,1);
            }
            if(Next[i] & (1LL<<j)){
                setHint(i,j + 10,1);
            }
        }
    }
}
void speedrun(int subtask, int N, int start){
    ll cur = start;
    while(cur != 1){
        cur = 0;
        f(j,0,10){
            if(getHint(j)){
                cur += (1LL<<j);
            }
        }
        assert(goTo(cur));
    }
    ll Next = 0;
    f(j,0,10){
        if(getHint(j + 10)){
            Next += (1LL<<j);
        }
    }
    while(Next != 0){
        if(goTo(Next)){
            Next = 0;
            f(j,0,10){
                if(getHint(j + 10)){
                    Next += (1LL<<j);
                }
            }
        }
        else{
            cur = 0;
            f(j,0,10){
                if(getHint(j)){
                    cur += (1LL<<j);
                }
            }
        }
    }
}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 464 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -