Submission #230649

#TimeUsernameProblemLanguageResultExecution timeMemory
230649Dilshod_ImomovLibrary (JOI18_library)C++17
0 / 100
3092 ms2648 KiB
#include <bits/stdc++.h> #include "library.h" using namespace std; const int N = 1e3 + 7; vector < int > adj[N], res; int used[N], cnt[N][N]; void dfs( int v, int ind ) { // cout << v << ' ' << ind << endl; res[ind] = v; used[v] = 1; for ( auto u: adj[v] ) { if ( !used[u] ) { dfs( u, ind + 1 ); } } } void Solve(int n) { vector < int > m(n); res.assign(n, 0); if ( n == 1 ) { res[0] = 1; Answer(res); return; } for ( int i = 1; i <= n; i++ ) { m[i - 1] = 1; for ( int j = 1; j <= n; j++ ) { if ( i == j || cnt[i][j] ) { continue; } cnt[i][j] = 1; m[j - 1] = 1; int x = Query(m); if ( x == 1 ) { adj[i].push_back( j ); } m[j - 1] = 0; } m[i - 1] = 0; } int start; for ( int i = 1; i <= n; i++ ) { // cout << i << ' ' << adj[i].size() << '\n'; if ( (int)adj[i].size() == 1 ) { start = i; break; } } dfs( start, 0 ); Answer(res); }

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:54:5: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
  dfs( start, 0 );
  ~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...