Submission #647490

#TimeUsernameProblemLanguageResultExecution timeMemory
647490LucaIlieSpeedrun (RMI21_speedrun)C++17
0 / 100
284 ms740 KiB
#include "speedrun.h" #include <bits/stdc++.h> using namespace std; const int MAX_N = 1000; const int MAX_LOG_N = 10; vector <int> edges[MAX_N + 1]; void setHints( int crt, int child, int bro, int parent ) { for ( int b = 0; b < MAX_LOG_N; b++ ) setHint( crt, b + 1, (child >> b) & 1 ); for ( int b = 0; b < MAX_LOG_N; b++ ) setHint( crt, b + 1 + MAX_LOG_N, (bro >> b) & 1 ); for ( int b = 0; b < MAX_LOG_N; b++ ) setHint( crt, b + 1 + 2 * MAX_LOG_N, (parent >> b) & 1 ); } void dfsAssignHints( int crt, int bro, int parent ) { int i = 0; while ( i < edges[crt].size() && edges[crt][i] == parent ) i++; setHints( crt, (i < edges[crt].size() ? edges[crt][i] : 0), bro, parent ); for ( int i = 0; i < edges[crt].size(); i++ ) { if ( edges[crt][i] != parent ) dfsAssignHints( edges[crt][i], (i + 1 < edges[crt].size() ? edges[crt][i + 1] : 0), crt ); } } void assignHints( int subtask, int n, int a[], int b[] ) { for ( int i = 1; i <= n - 1; i++ ) { edges[a[i]].push_back( b[i] ); edges[b[i]].push_back( a[i] ); } setHintLen( 3 * MAX_LOG_N ); dfsAssignHints( 1, 0, 0 ); } bool visited[MAX_N + 1]; void getHints( int crt, int &child, int &bro, int &parent ) { child = 0; for ( int b = 0; b < MAX_LOG_N; b++ ) child += (getHint( b + 1 ) << b); bro = 0; for ( int b = 0; b < MAX_LOG_N; b++ ) bro += (getHint( b + 1 + MAX_LOG_N ) << b); parent = 0; for ( int b = 0; b < MAX_LOG_N; b++ ) parent += (getHint( b + 1 + 2 * MAX_LOG_N ) << b); } void dfsSpeedrun( int crt ) { int child, bro, parent; visited[crt] = true; getHints( crt, child, bro, parent ); if ( !visited[child] && goTo( child ) ) { dfsSpeedrun( child ); goTo( crt ); } if ( !visited[parent] && goTo( parent ) ) { dfsSpeedrun( parent ); goTo( crt ); } if ( !visited[bro] && goTo( parent ) ) { if ( goTo( bro ) ) { dfsSpeedrun( bro ); goTo( parent ); } goTo( crt ); } } void speedrun( int subtask, int n, int start ) { visited[start] = true; dfsSpeedrun( start ); }

Compilation message (stderr)

speedrun.cpp: In function 'void dfsAssignHints(int, int, int)':
speedrun.cpp:22:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  while ( i < edges[crt].size() && edges[crt][i] == parent )
      |          ~~^~~~~~~~~~~~~~~~~~~
speedrun.cpp:24:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  setHints( crt, (i < edges[crt].size() ? edges[crt][i] : 0), bro, parent );
      |                  ~~^~~~~~~~~~~~~~~~~~~
speedrun.cpp:25:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for ( int i = 0; i < edges[crt].size(); i++ ) {
      |                   ~~^~~~~~~~~~~~~~~~~~~
speedrun.cpp:27:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |    dfsAssignHints( edges[crt][i], (i + 1 < edges[crt].size() ? edges[crt][i + 1] : 0), crt );
      |                                    ~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...