Submission #1270549

#TimeUsernameProblemLanguageResultExecution timeMemory
1270549efegSpeedrun (RMI21_speedrun)C++20
0 / 100
0 ms504 KiB
#include <bits/stdc++.h>
#include "speedrun.h"
using namespace std; 

#define pb push_back
const int N = 1024; 

vector<int> par(N,1023),nxt(N,1023); 
vector<int> adj[N];
vector<int> liste; 

void dfs(int node,int p){
    if (p != -1) par[node] = p; 
    liste.pb(node); 
    for (auto x : adj[node]){
        if (x == p) continue;
        dfs(x,node); 
    }
}

void assignHints(int subtask, int n, int a[], int b[]) { 
    for (int i = 1; i < n; i++){
        adj[a[i]-1].pb(b[i]-1);
        adj[b[i]-1].pb(a[i]-1); 
    }
    dfs(0,-1); 
    for (int i = 0; i < n; i++){
        nxt[liste[i]] = liste[(i+1) % n];  
    }
    setHintLen(20);
    for (int node = 0; node < n; node++){
        cout << node << " " << par[node] << " " << nxt[node] << endl; 
        for (int bit = 0; bit < 10; bit++){
            if (nxt[node] & (1 << bit)){
                setHint(node+1,bit + 1,1); 
            }

        }   
        for (int bit = 0; bit < 10; bit++){
            if (par[node] & (1 << bit)){
                setHint(node+1,bit + 11,1); 
            }
        }
    }
}

void speedrun(int subtask, int n, int start) {
    int l = getLength();
    int curr = start-1; 
    do {
        int nxt = 0,par = 0; 
        for (int bit = 0; bit < 10; bit++){
            if (getHint(bit+1)) nxt += (1 << bit); 
        }
        for (int bit = 0; bit < 10; bit++){
            if (getHint(bit+11)) par += (1 << bit); 
        }
//        cout << curr << " " << nxt << " " << par << endl;
        if (goTo(nxt+1)){
            curr = nxt; 
        }
        else {
            goTo(par+1);
            curr = par; 
        }
    } while (curr != start-1); 
}
#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...