Submission #772569

#TimeUsernameProblemLanguageResultExecution timeMemory
772569khshgStations (IOI20_stations)C++14
0 / 100
735 ms416 KiB
#include"stations.h" #include<bits/stdc++.h> using namespace std; vector<vector<int>> adj; vector<int> label(int N, int K, vector<int> u, vector<int> v) { adj.resize(N); for(auto& I : adj) I.clear(); for(int i = 0; i < (int)u.size(); ++i) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } vector<int> flat(N); int root = -1; for(int i = 0; i < N; ++i) { if((int)adj[i].size() == 1) { root = i; break; } } vector<int> labels(N); int cur = root, prev = -1; for(int i = 0; ; ++i) { flat[i] = cur; labels[cur] = i; if(i == N - 1) break; bool f = (adj[i][0] == prev); prev = cur; cur = adj[i][f]; } return labels; } int find_next_station(int s, int t, vector<int> c) { if(s > t) { 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...