# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
943848 | thunopro | Speedrun (RMI21_speedrun) | C++14 | 0 ms | 0 KiB |
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>
using namespace std ;
#define maxn 1009
#define ll long long
#define pb push_back
#define fi first
#define se second
#define left id<<1
#define right id<<1|1
#define re exit(0);
#define _lower(x) lower_bound(v.begin(),v.end(),x)-v.begin()+1
#define TIME ( 1.0*clock() / CLOCKS_PER_SEC )
const int mod = 1e9+7 ;
const int INF = 1e9 ;
typedef vector<int> vi ;
typedef pair<int,int> pii ;
typedef vector<pii> vii ;
template < typename T > void chkmin ( T &a , T b ) { if ( a > b ) a = b ; }
template < typename T > void chkmax ( T &a , T b ) { if ( a < b ) a = b ; }
void add ( int &a , int b )
{
a += b ;
if ( a >= mod ) a -= mod ;
if ( a < 0 ) a += mod ;
}
void rf ()
{
freopen ("bai1.inp","r",stdin) ;
}
mt19937 rng (time(0)) ;
int _pow ( int a , int n )
{
if ( n == 0 ) return 1 ;
int res = _pow (a,n/2) ;
if ( n % 2 ) return 1ll*res*res%mod*a%mod ;
else return 1ll*res*res%mod ;
}
#include "speedrun.h"
//int bit [maxn] ;
//int LENGTH ;
//int cur ;
//bool adj [maxn][maxn] ;
//
//void setHintLen ( int l )
//{
// LENGTH = l ;
//}
//void setHint ( int i , int j , bool b )
//{
// bit [i] |= (1<<j) ;
//}
//int getLength ()
//{
// return LENGTH ;
//}
//bool getHint ( int j )
//{
// return (bit[cur]>>(j-1)) ;
//}
//bool goTo ( int x )
//{
// if ( adj [cur][x] == true )
// {
// cur = x ;
// return true ;
// }
//}
vi adjList [maxn] ;
int par [maxn] ;
int euler [maxn] , timeDfs ;
void dfs ( int u , int dfs_par = 0 )
{
par [u] = dfs_par ;
euler [timeDfs++] = u ;
for ( auto v : adjList [u] )
{
if ( v != dfs_par )
{
dfs (v,u) ;
}
}
}
void setInterger ( int node , int id , int value )
{
int offset = id*10+1 ;
for ( int b = 0 ; b < 10 ; b ++ )
{
if ( value>>b&1 ) setHint (node,offset+b,true) ;
}
}
void assignHints ( int subtask , int n , vi A , vi B )
{
setHintLen (20) ;
for ( int i = 1 ; i <= n-1 ; i ++ )
{
int u = A [i] , v = B [i] ;
adjList [u] . pb (v) , adjList [v] . pb (u) ;
}
dfs (1) ;
for ( int i = 0 ; i < n ; i ++ )
{
setInterger (i+1,0,par[i+1]) ;
setInterger (euler[i],1,euler[(i+1)%n]) ;
}
}
int readInterger ( int id )
{
int offset = id*10+1 ;
int value = 0 ;
for ( int b = 0 ; b < 10 ; b ++ )
{
value += (getHint(offset+b)<<b) ;
}
return value ;
}
void speedrun ( int subtask , int n , int start )
{
int node = start ;
do {
int target = readInterger (1) ;
while (!goTo(target))
{
node = readInterger (0) ;
goTo (node) ;
}
node = target ;
} while ( node != start ) ;
}
//int main ()
//{
// ios_base::sync_with_stdio(0);
// cin.tie(0);cout.tie(0);
//// rf () ;
//
//}