Submission #742762

# Submission time Handle Problem Language Result Execution time Memory
742762 2023-05-16T20:58:16 Z MilosMilutinovic Speedrun (RMI21_speedrun) C++14
0 / 100
1 ms 464 KB
#include "speedrun.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2002;
int par[N], idx[N];
vector<int> g[N], order;
void dfs(int x, int fa) {
    par[x] = fa;
    idx[x] = (int) order.size();
    order.push_back(x);
    for (int y : g[x]) if (y != fa) dfs(y, x);
}
void assignHints(int subtask, int n, int a[], int b[]) {
    for (int i = 1; i < n; i++) {
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    dfs(1, 0);
    setHintLen(20);
//    printf("-- %d\n", order[idx[1] + 1]);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 10; j++) setHint(i, j, par[i] >> j & 1);
        if (idx[i] + 1 < n)  for (int j = 0; j < 10; j++) setHint(i, 10 + j, order[idx[i] + 1] >> j & 1);
        else for (int j = 0; j < 10; j++) setHint(i, 10 + j, order[idx[i] + 1] >> j & 1);
    }
}
int getPar() {
    int x = 0;
    for (int i = 0; i < 10; i++) if (getHint(i)) x += (1 << i);
    return x;
}
int getChild() {
    int x = 0;
    for (int i = 0; i < 10; i++) if (getHint(i + 10)) x += (1 << i);
    return x;
}
vector<int> stk;
void go(int x, int fa) {
    int ch = getChild();
    if (ch != 0) stk.push_back(ch);
//    printf("trcim iz %d   kid=%d\n", x, ch);
    while (!stk.empty()) {
        int y = stk.back();
        if (goTo(y)) {
            stk.pop_back();
            go(y, x);
            goTo(x);
        } else break;
    }
}
void speedrun(int subtask, int N, int start) {
    while (getPar() != 0) {
        int nxt = getPar();
        goTo(nxt);
        start = nxt;
    }
    go(start, start);
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 464 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -