답안 #687549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
687549 2023-01-26T14:30:26 Z QwertyPi Speedrun (RMI21_speedrun) C++14
100 / 100
213 ms 980 KB
#include "speedrun.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 1024;
vector<int> G[N]; int p[N];
vector<int> preord;

int getHintL(int i){
    int ret = 0;
    for(int j = 0; j < 10; j++){
        ret += getHint(i * 10 + j + 1) * (1 << j);
    }
    return ret;
}

void setHintL(int v, int i, int val){
    for(int j = 0; j < 10; j++){
        setHint(v, i * 10 + j + 1, (val & (1 << j)) > 0);
    }
}

void dfs(int v, int pa = -1){
    preord.push_back(v);
    for(auto i : G[v]){
        if(i != pa){
            dfs(i, v); setHintL(i, 0, v);
        }
    }
}

int nxt = 1;
void dfs2(int v, int pa = -1){
    nxt = getHintL(1);
    while(nxt != 0x3ff){
        if(!goTo(nxt)) {
            goTo(getHintL(0));
            return;
        } else {
            dfs2(nxt, v);
        }
    }
}

void assignHints(int subtask, int N, int A[], int B[]) {
    setHintLen(20);
    for(int i = 1; i <= N - 1; i++){
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    setHintL(1, 0, 0x3ff); dfs(1);
    for(int i = 0; i < N - 1; i++) setHintL(preord[i], 1, preord[i + 1]);
    setHintL(preord[N - 1], 1, 0x3ff);
}

void speedrun(int subtask, int N, int start) {
    int x = getHintL(0);
    while(x != 0x3ff) {
        goTo(x); x = getHintL(0);
    }
    dfs2(start);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 192 ms 868 KB Output is correct
2 Correct 213 ms 736 KB Output is correct
3 Correct 183 ms 672 KB Output is correct
4 Correct 131 ms 936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 190 ms 788 KB Output is correct
2 Correct 181 ms 712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 189 ms 800 KB Output is correct
2 Correct 175 ms 756 KB Output is correct
3 Correct 182 ms 800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 180 ms 796 KB Output is correct
2 Correct 185 ms 792 KB Output is correct
3 Correct 138 ms 772 KB Output is correct
4 Correct 184 ms 764 KB Output is correct
5 Correct 201 ms 848 KB Output is correct
6 Correct 186 ms 792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 724 KB Output is correct
2 Correct 188 ms 980 KB Output is correct
3 Correct 181 ms 724 KB Output is correct
4 Correct 147 ms 772 KB Output is correct
5 Correct 119 ms 784 KB Output is correct
6 Correct 188 ms 728 KB Output is correct
7 Correct 200 ms 792 KB Output is correct