제출 #819707

#제출 시각아이디문제언어결과실행 시간메모리
819707Alihan_8기지국 (IOI20_stations)C++17
10 / 100
774 ms556 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define pb push_back #define ln '\n' //#define int long long template <class _T> bool chmin(_T &x, const _T &y){ bool flag = false; if ( x > y ){ x = y; flag |= true; } return flag; } template <class _T> bool chmax(_T &x, const _T &y){ bool flag = false; if ( x < y ){ x = y; flag |= true; } return flag; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector <int> g[n]; for ( int i = 0; i + 1 < n; i++ ){ g[u[i]].pb(v[i]); g[v[i]].pb(u[i]); } vector <int> ans(n, -1); ans[0] = 0; function <void(int)> dfs = [&](int x){ int cnt = 1; for ( auto to: g[x] ){ if ( ans[to] == -1 ){ ans[to] = ans[x] * 8 + cnt; cnt++; dfs(to); } } }; dfs(0); return ans; } int find_next_station(int s, int t, vector<int> c) { while ( t > 0 ){ if ( t / 8 == s ){ return t; } t /= 8; } return s / 8; }
#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...