Submission #772457

#TimeUsernameProblemLanguageResultExecution timeMemory
772457SanguineChameleonStations (IOI20_stations)C++17
5 / 100
842 ms672 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 20; vector<int> adj[maxn]; int tin[maxn]; int tout[maxn]; int dfs_t = -1; void dfs(int u, int p) { tin[u] = ++dfs_t; for (auto v: adj[u]) { if (v != p) { dfs(v, u); } } tout[u] = dfs_t; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for (int i = 0; i < n; i++) { adj[i].clear(); } for (int i = 0; i < n - 1; i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs_t = -1; for (int i = 0; i < n; i++) { if ((int)adj[i].size() == 1) { dfs(i, -1); break; } } vector<int> labels(n); for (int i = 0; i < n; i++) { labels[i] = tin[i]; } return labels; } int find_next_station(int s, int t, vector<int> c) { if (s < t) { return s + 1; } else { return s - 1; } }
#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...