# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
431385 | 2021-06-17T11:32:09 Z | idk321 | Stations (IOI20_stations) | C++17 | 0 ms | 0 KB |
#include "stations.h" #include <vector> using namespace std; const int M = 1000000000; const int N = 1000; int in[N]; int out[N]; vector<int> adj[N]; vector<int> labels; int n, k; int timer; void dfs2(int node, int par) { timer++; in[node] = timer; for (int next : adj[node]) { if (next == par) continue; dfs2(next, node); } out[node] = timer; } std::vector<int> label(int n1, int k1, std::vector<int> u, std::vector<int> v) { n = n1; k = k1; labels.assign(n, 0); for (int i = 0; i < n; i++) adj[i].clear(); for (int i = 0; i < u.size(); i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } for (int i = 0; i < n; i++) { labels[i] = i } return labels; } int find_next_station(int s, int t, std::vector<int> c) { vector<int> path; path.push_back(t); while (true) { t /= 2; path.push_back(t); if (t == 0) break; } bool contain = false; for (int i : path) { if (i == s) contain = true; } if (!contain) return s / 2; for (int i : path) { for (int j : c) { if (j == s / 2) continue; if (j == i) return i; } } return c[0]; }