Submission #979307

#TimeUsernameProblemLanguageResultExecution timeMemory
979307ZicrusStations (IOI20_stations)C++17
5 / 100
572 ms1172 KiB
#include <bits/stdc++.h> #include "stations.h" using namespace std; vector<int> lbl; vector<vector<int>> adj; void DFS(int index, int last, int id) { lbl[index] = id; for (auto node : adj[index]) { if (node == last) continue; DFS(node, index, id + 1); } } vector<int> label(int N, int K, vector<int> U, vector<int> V) { adj = vector<vector<int>>(N); lbl = vector<int>(N); for (int i = 0; i < N - 1; i++) { adj[U[i]].push_back(V[i]); adj[V[i]].push_back(U[i]); } for (int i = 0; i < N; i++) { if (adj[i].size() == 1) { DFS(i, -1, 0); break; } } return lbl; } int find_next_station(int S, int T, vector<int> C) { if (T > S) { return S + 1; } 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...