Submission #359462

#TimeUsernameProblemLanguageResultExecution timeMemory
359462Dilshod_ImomovStations (IOI20_stations)C++17
0 / 100
1000 ms1068 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int N = 1e3 + 7; vector < int > lb, adj[N]; int num, timer = 1; std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { for ( int i = 0; i < n; i++ ) { adj[i].clear(); } for ( int i = 0; i < n - 1; i++ ) { int x = u[i], y = v[i]; adj[x].push_back(y); adj[y].push_back(x); } num = 0; lb.clear(); lb.resize(n); queue < int > q; q.push( 0 ); vector < int > used(n + 1); used[0] = 1; while ( !q.empty() ) { int v = q.front(); q.pop(); lb[v] = num++; for ( auto u: adj[v] ) { if ( !used[u] ) { q.push( u ); used[u] = 1; } } } return lb; } bool is_ancestor( int b, int a ) { if ( b == 0 ) { return 1; } int pr = (a - 1) / 2; while ( pr > 0 ) { if ( pr == b ) { return 1; } pr = (pr - 1) / 2; } return 0; } int find_next_station(int s, int t, std::vector<int> c) { if ( is_ancestor( t, s ) ) { return (s - 1) / 2; } if ( is_ancestor( s * 2, t ) ) { return s * 2; } return s * 2 + 1; }
#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...