Submission #1009888

#TimeUsernameProblemLanguageResultExecution timeMemory
1009888dimashhhStations (IOI20_stations)C++17
0 / 100
7 ms10072 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 12; vector<int> g[N],ord; bool vis[N]; vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v){ vector<int> lab(n); for(int i = 0;i < n;i++){ lab[i] = i; vis[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]); } queue<int> q; for(int i = 0;i < n;i++){ if((int)g[i].size() == 1){ q.push(i); vis[i] = 1; break; } } while(!q.empty()){ int v = q.front(); ord.push_back(v); q.pop(); for(int to:g[v]){ if(!vis[to]){ vis[to] = 1; q.push(to); } } } assert((int)ord.size() == n); // for(int i = 0;i < (int)ord.size();i++){ // lab[ord[i]] = i; // } return lab; } int find_next_station(int s, int t, std::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...