제출 #828808

#제출 시각아이디문제언어결과실행 시간메모리
828808Minindu206기지국 (IOI20_stations)C++14
0 / 100
654 ms636 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; vector<int> vals; int t = 0; void dfs(vector<vector<int>> &adj, int node, int p) { if(p == -1 || vals[p] == 0) vals[node] = t++; for (auto a : adj[node]) { if (a != p) dfs(adj, a, node); } if(vals[node] == 0) vals[node] = t++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<vector<int>> adj(n + 1); for (int i = 0; i < n - 1; i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } vals.resize(n, 0); dfs(adj, 0, -1); // for (int i = 0; i < n; i++) // cout << vals[i] << "\n"; // cout << '\n'; return vals; } 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...