Submission #500324

# Submission time Handle Problem Language Result Execution time Memory
500324 2021-12-30T18:14:46 Z talant117408 Speedrun (RMI21_speedrun) C++17
0 / 100
107 ms 712 KB
#include "speedrun.h"
#include <bits/stdc++.h>
//~ #include <ext/pb_ds/assoc_container.hpp>
 
//~ using namespace __gnu_pbds;
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
//~ typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) ll((v).size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define OK cout << "OK" << endl;

const int MAXN = 1e3+7;
vector <int> graph[MAXN];
int parent[MAXN];
vector <int> stacc, used(MAXN);
int n;
int len;

void set_to_child(int from, int to) {
    for (int bit = 0; bit < 10; bit++) {
        if (to & (1 << bit)) {
            setHint(from, bit+1, 1);
        }
    }
}

void set_to_parent(int from, int to) {
    for (int bit = 0; bit < 10; bit++) {
        if (to & (1 << bit)) {
            setHint(from, bit+11, 1);
        }
    }
}

void set_dfs(int v, int p = 0) {
    if (used[v]) {
        return;
    }
    parent[v] = p;
    used[v] = 1;
    stacc.pb(v);
    for (auto to : graph[v]) {
        set_dfs(to, v);
    }
}

void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */
    setHintLen(20);
    n = N;
    for (int i = 1; i < n; i++) {
        graph[A[i]].pb(B[i]);
        graph[B[i]].pb(A[i]);
    }
    set_dfs(1);
    for (int i = 0; i < sz(stacc); i++) {
        set_to_child(stacc[i], stacc[(i+1)%n]);
        set_to_parent(stacc[i], parent[stacc[i]]);
    }
}

int get_child() {
    int res = 0;
    for (int bit = 0; bit < 10; bit++) {
        if (getHint(bit+1)) {
            res += (1 << bit);
        }
    }
    return res;
}

int get_parent() {
    int res = 0;
    for (int bit = 0; bit < 10; bit++) {
        if (getHint(bit+11)) {
            res += (1 << bit);
        }
    }
    return res;
}

void speedrun(int subtask, int N, int start) { /* your solution here */
    len = getLength();
    set <int> st;
    int nxt = 0;
    while (sz(st) < n) {
        st.insert(start);
        if (nxt) {
            pii a = mp(get_child(), get_parent());
            goTo(nxt);
            pii b = mp(get_child(), get_parent());
            if (a == b) {
                goTo(start = get_parent());
            }
            else {
                start = nxt;
                nxt = 0;
            }
        }
        else {
            pii a = mp(get_child(), get_parent());
            int ch = get_child();
            goTo(ch);
            pii b = mp(get_child(), get_parent());
            if (a == b) {
                nxt = ch;
                goTo(start = get_parent());
            }
            else {
                start = ch;
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 660 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 107 ms 660 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 660 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 96 ms 712 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 97 ms 668 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -