Submission #967493

#TimeUsernameProblemLanguageResultExecution timeMemory
967493WendidIask0303Stations (IOI20_stations)C++17
0 / 100
580 ms936 KiB
#include "stations.h" #include <vector> using namespace std; vector<int> adj[1001]; vector<int> a; bool vis[1001]; int timer = 0; void dfs(int u, int t){ if (t == 0){ a[u] = timer; timer++; } vis[u] = true; for (auto v:adj[u]){ if (vis[v]) continue; dfs(v, t); } if (t == 1){ a[u] = timer; timer++; } } vector<int> label(int n, int k, vector<int> u, vector<int> v){ timer = 0; a.clear(); a.resize(n); for (int i=0; i<n; i++){ adj[i].clear(); vis[i] = false; } for (int i=0; i<n-1; i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0, 0); return a; } int find_next_station(int s, int t, vector<int> c){ if (c[c.size()-1] < s){ int ans = c[0]; for (auto x:c){ if (min(s, x) <= t && t <= max(s, x)) ans = x; } return ans; } else { for (auto x:c){ if (min(s, x) <= t && t <= max(s, x)) return x; } return c[c.size()-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...