Submission #604879

#TimeUsernameProblemLanguageResultExecution timeMemory
604879HamletPetrosyanStations (IOI20_stations)C++17
5 / 100
1079 ms592 KiB
#include "stations.h" #include <vector> #include <iostream> using namespace std; #define ll long long #define add push_back #define len(a) ((int)(a).size()) vector<int> g[1005]; vector<int> labels; int timer = -2; void dfs(int v, int p){ labels[v] = timer++; for(int i = 0; i < len(g[v]); i++){ int to = g[v][i]; if(to == p) continue; dfs(to, v); } } vector<int> label(int n, int k, vector<int> u, vector<int> v) { labels.resize(n); timer = 0; for(int i = 0; i < n; i++) { g[i].clear(); } for(int i = 0; i < len(u); i++){ g[u[i]].add(v[i]); g[v[i]].add(u[i]); } for(int i = 0; i < n; i++){ if(len(g[i]) == 1) { dfs(i, i); break; } } 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...