Submission #1104330

# Submission time Handle Problem Language Result Execution time Memory
1104330 2024-10-23T13:25:29 Z M_W_13 Speedrun (RMI21_speedrun) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
#include "speedrun.h"

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)

const int MAXN = 1001;
vector<int> graf[MAXN];
vector<int> kolejnosc;

void dfset(int v, int last) {
    kolejnosc.push_back(v);
    int x = 1;
    for (int j = 11; j <= 20; j++) {
        if ((x & last) == x) {
            setHint(v, j, 1);
        }
        else {
            setHint(v, j, 0);
        }
        x *= 2;
    }
    for (auto syn: graf[v]) {
        if (syn == last) {
            continue;
        }
        dfset(syn, v);
    }
}

void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */
    setHintLen(20);
    for (int i = 1; i < N; i++) {
        // cout << "i = " << i << endl;
        // cout << A[i] << " " << B[i] << endl;
        graf[A[i]].push_back(B[i]);
        graf[B[i]].push_back(A[i]);
    }
    // cout << "TU1" << endl;
    dfset(0, 0);
    // cout << "TU2" << endl;
    rep(i, N - 1) {
        int v = kolejnosc[i];
        int w = kolejnosc[(i + 1) % N];
        int x = 1;
        for (int j = 1; j <= 10; j++) {
            if ((x & w) == x) {
                setHint(v, j, 1);
            }
            else {
                setHint(v, j, 0);
            }
            x *= 2;
        }
    }
}
const int MAXN2 = 1001;
bool czy[MAXN2];

int dfs(int v, int last) {
    czy[v] = true;
    // cout << "v = " << v << endl;
    int nowy = 0;
    int x = 1;
    for (int j = 1; j <= 10; j++) {
        if (getHint(j)) {
            nowy += x;
        }
        x *= 2;
    }
    // cout << "nowy = " << nowy << '\n';
    if (czy[nowy]) {
        goTo(last);
        return nowy;
    }
    while (!czy[nowy] && goTo(nowy)) {
        nowy = dfs(nowy, v);
    }
    goTo(last);
    return nowy;
}

void speedrun(int subtask, int N, int start) { /* your solution here */
    getLength();
    int v = start;
    while (v != 0) { 
        int nekst = 0;
        int x = 1;
        for (int j = 11; j <= 20; j++) {
            if (getHint(j)) {
                nekst += x;
            }
            x *= 2;
        }
        goTo(nekst);
        v = nekst;
    }
    dfs(0, 0);
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Invalid node index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Invalid node index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Invalid node index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Invalid node index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Invalid node index for setHint
2 Halted 0 ms 0 KB -