Submission #498837

# Submission time Handle Problem Language Result Execution time Memory
498837 2021-12-26T12:43:18 Z SlavicG Speedrun (RMI21_speedrun) C++17
0 / 100
269 ms 712 KB
#include "speedrun.h"
#include "bits/stdc++.h"
using namespace std;
 
#define pb push_back
#define sz(a) (int)a.size()
 
/*
void setHintLen (int l){}
void setHint(int i, int j, bool b){}
int getLength(){}
bool getHint(int j){}
bool goTo(int x){}
*/
 
vector<int> st;
void dfsHint(int u, int par, vector<vector<int>>& adj, vector<int>& parent){
    st.pb(u);
    parent[u] = par;
    for(int v: adj[u]){
        if(v == par)continue;
        dfsHint(v, u, adj, parent);
    }
}
void assignHints(int subtask , int n, int a[], int b[]){
    setHintLen(30);
 
    vector<vector<int>> adj(n + 1);
    for(int i = 1;i <= n - 1; ++i){
        adj[a[i]].pb(b[i]);
        adj[b[i]].pb(a[i]);
    }  
    vector<int> right_neighbor(n + 1, 0), parent(n + 1, 0), left_child(n + 1, 0);
    dfsHint(1, 0, adj, parent);
    
    vector<int> nxt(n + 1, 0);
    for(int i = 0;i < sz(st); ++i){
        nxt[st[i]] = st[(i + 1) % sz(st)];
    }

    for(int i = 1;i <= n; ++i){
        int idx = 1;
        for(int j = 9;j >= 0; --j){
            if(parent[i] & (1 << j))setHint(i, idx, 1);
            ++idx;
        }
        for(int j = 9;j >= 0; --j){
            if(nxt[i] & (1 << j))setHint(i, idx, 1);
            ++idx;
        }
    }
}

int cnt;
void dfs(int u, vector<bool>& vis){
    if(!vis[u])--cnt;
    vis[u] = true;
    if(!cnt)exit(0);
    int par = 0, nxt = 0, idx = 1;
 
    for(int j = 9;j >= 0; --j){
        if(getHint(idx))par += (1 << j);
        ++idx;
    }
    for(int j = 9;j >= 0; --j){
        if(getHint(idx))nxt += (1 << j);
        ++idx;
    }

    bool x = goTo(nxt);
    if(x)dfs(nxt, vis);
    else{
        dfs(par, vis);
    }

}
void speedrun(int subtask, int n, int start){
    int l = getLength();
    vector<bool> vis(n + 1, false);
    cnt = n;
    dfs(start, vis);
}
 
/*
int main(){
 
}
*/

Compilation message

speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:78:9: warning: unused variable 'l' [-Wunused-variable]
   78 |     int l = getLength();
      |         ^
# Verdict Execution time Memory Grader output
1 Incorrect 103 ms 712 KB Used too many wrong interactions
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB The length is too large
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 328 KB The length is too large
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 269 ms 532 KB Used too many wrong interactions
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 110 ms 576 KB Used too many wrong interactions
2 Halted 0 ms 0 KB -