제출 #777059

#제출 시각아이디문제언어결과실행 시간메모리
777059Trisanu_Das기지국 (IOI20_stations)C++17
100 / 100
825 ms760 KiB
#include <bits/stdc++.h> using namespace std; vector<int> adj[1000], U, V, labelling; int N, K, curr_tag; void dfs(int u, int p){ if(p == -1 || !labelling[p]) labelling[u] = ++curr_tag; for(int v : adj[u]) if(v != p) dfs(v, u); if(!labelling[u]) labelling[u] = ++curr_tag; } vector<int> label(int n, int k, vector<int> u, vector<int> v){ N = n; K = k; U = u, V = v; for(int i = 0; i < n; i++) adj[i].clear(); labelling.clear(); labelling.resize(n, 0); curr_tag = 0; for(int i = 0; i < n - 1; i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0, -1); return labelling; } int find_next_station(int s, int t, vector<int> c){ if(c.back() < s) reverse(c.begin(), c.end()); for(int x : c) if(min(s, x) <= t && t <= max(s, x)) return x; return c.back(); }
#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...