Submission #971411

#TimeUsernameProblemLanguageResultExecution timeMemory
971411emad234Stations (IOI20_stations)C++17
0 / 100
573 ms984 KiB
#include <bits/stdc++.h> #define ll long long #define F first #define S second #define pii pair<int, int> using namespace std; vector<int> labelss, pre, post; vector<vector<int>> gr; int id; void dfs(int u, int par, int d) { pre[u] = ++id; if (d % 2 == 0) labelss[u] = pre[u]; for (auto x : gr[u]) { if (x == par) continue; dfs(x, u, d + 1); } post[u] = ++id; if(d % 2) labelss[u] = post[u]; } vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { gr.clear(); post.clear(); pre.clear(); labelss.clear(); gr.resize(n + 1); labelss.resize(n); post.resize(n); pre.resize(n); for (int i = 0; i < n - 1; i++) { gr[u[i]].push_back(v[i]); gr[v[i]].push_back(u[i]); } dfs(0, -1, 0); return labelss; } int find_next_station(int s, int t, std::vector<int> c) { bool pst = 1; int root = -1; sort(c.begin(), c.end()); for (auto x : c) { if (x > s) pst = 0; } for (auto x : c) { if (pst) root == -1 ? root = x : root = min(root, x); else root = max(x, root); } int id = root; if (pst) { for (auto x : c) { if(x == root) continue; if (x > t) break; else id = x; } if (s < t) id = root; } else { for (auto x : c) { if (x == root) continue; if (x > t) { id = x; break; } } } return id; }
#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...