답안 #500326

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500326 2021-12-30T18:17:16 Z talant117408 Speedrun (RMI21_speedrun) C++17
0 / 100
196 ms 724 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);
        }
        else {
            setHint(from, bit+1, 0);
        }
    }
}

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

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;
}

/* 
5 
1 2
2 3 
3 4
3 5
2
*/

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;
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 181 ms 660 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 178 ms 660 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 158 ms 660 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 196 ms 724 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 163 ms 664 KB Solution didn't visit every node
2 Halted 0 ms 0 KB -