This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "speedrun.h"
using namespace std;
const int NMAX = 1000;
vector <int> edges[NMAX + 1];
int p[NMAX + 1];
vector <int> ord;
int nxt[NMAX + 1];
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 );
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |