Submission #1089281

#TimeUsernameProblemLanguageResultExecution timeMemory
1089281T0p_Stations (IOI20_stations)C++14
5 / 100
608 ms940 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int N = 1000; int degree[N]; vector<int> g[N], lbl; void dfs(int u, int p, int l) { lbl[u] = l; for (int v : g[u]) { if (v == p) { continue; } dfs(v, u, l+1); } } vector<int> label(int n, int k, vector<int> u, vector<int> v) { lbl = vector<int>(n); for (int i=0 ; i<n ; i++) { degree[i] = 0; g[i].clear(); } for (int i=0 ; i<n-1 ; i++) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); degree[u[i]]++; degree[v[i]]++; } for (int i=0 ; i<n ; i++) { if (degree[i] == 1) { dfs(i, -1, 0); break; } } return lbl; } int find_next_station(int s, int t, vector<int> c) { return s < t ? s+1 : 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...