Submission #647017

# Submission time Handle Problem Language Result Execution time Memory
647017 2022-10-01T11:21:13 Z Tudy006 Speedrun (RMI21_speedrun) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "speedrun.h"
using namespace std;

void dfs( int node, int father ) {
    p[node] = father;
    ord.push_back( node );
    for ( auto it : edges[node] ) {
        if ( it == father ) continue;
        dfs( it, node );
    }
}
void assignHints( int subtask, int n, int a[], int b[] ) {
    for ( int i = 1; i < n; i ++ ) {
        edges[a[i]].push_back( b[i] );
        edges[b[i]].push_back( a[i] );
    }
    dfs( 1, 0 );
    for ( int i = 0; i < n; i ++ ) nxt[ord[i]] = ord[( i + 1 ) % n];
    setHintLen( 20 );
    for ( int i = 1; i <= n; i ++ ) {
        for ( int j = 9; j >= 0; j -- ) {
            if ( p[i] & ( 1 << j ) )
                setHint( i, 10 - j, 1 );
        }
        for ( int j = 9; j >= 0; j -- ) {
            if ( nxt[i] & ( 1 << j ) )
                setHint( i, 20 - j, 1 );
        }
    }
}
int getp() {
    int f = 0;
    for ( int i = 1; i <= 10; i ++ ) f = f * 2 + getHint( i );
    return f;
}
int getnxt() {
    int x = 0;
    for ( int i = 11; i <= 20; i ++ ) x = x * 2 + getHint( i );
    return x;
}
void speedrun( int subtask, int n, int node ) {
    int f;
    while ( ( f = getp() ) != 0 ) {
        goTo( f );
        node = f;
    }
    do {
        int x = getnxt();
        if ( goTo( x ) ) {
            node = x;
        } else {
            do {
                f = getp();
                goTo( f );
                node = f;
            } while ( !goTo( x ) );
            node = x;
        }
    } while ( getnxt() != 1 );
}

Compilation message

speedrun.cpp: In function 'void dfs(int, int)':
speedrun.cpp:6:5: error: 'p' was not declared in this scope
    6 |     p[node] = father;
      |     ^
speedrun.cpp:7:5: error: 'ord' was not declared in this scope
    7 |     ord.push_back( node );
      |     ^~~
speedrun.cpp:8:21: error: 'edges' was not declared in this scope
    8 |     for ( auto it : edges[node] ) {
      |                     ^~~~~
speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:15:9: error: 'edges' was not declared in this scope
   15 |         edges[a[i]].push_back( b[i] );
      |         ^~~~~
speedrun.cpp:19:36: error: 'nxt' was not declared in this scope
   19 |     for ( int i = 0; i < n; i ++ ) nxt[ord[i]] = ord[( i + 1 ) % n];
      |                                    ^~~
speedrun.cpp:19:40: error: 'ord' was not declared in this scope
   19 |     for ( int i = 0; i < n; i ++ ) nxt[ord[i]] = ord[( i + 1 ) % n];
      |                                        ^~~
speedrun.cpp:23:18: error: 'p' was not declared in this scope
   23 |             if ( p[i] & ( 1 << j ) )
      |                  ^
speedrun.cpp:27:18: error: 'nxt' was not declared in this scope
   27 |             if ( nxt[i] & ( 1 << j ) )
      |                  ^~~