Submission #757634

#TimeUsernameProblemLanguageResultExecution timeMemory
7576341binStations (IOI20_stations)C++14
100 / 100
979 ms792 KiB
#include <bits/stdc++.h> #include <stations.h> using namespace std; #define all(v) v.begin(), v.end() typedef long long ll; const int NMAX = 1005; int t; vector<int> adj[NMAX]; void dfs(int x, int p, int f, vector<int>& labels){ if(!f) labels[x] = t++; for(int&nx : adj[x]) if(nx != p) dfs(nx, x, f ^ 1, labels); if(f) labels[x] = t++; return; } vector<int>label(int n, int k, vector<int> u, vector<int> v) { vector<int> labels(n); for(int i = 0; i < n - 1; i++){ adj[u[i]].emplace_back(v[i]); adj[v[i]].emplace_back(u[i]); } t = 0; dfs(0, -1, 0, labels); for(int i = 0; i < n; i++) adj[i].clear(); return labels; } int find_next_station(int s, int t, vector<int> c) { int sz = c.size(); if(s < c[0]){ for(int i = 0; i < sz; i++){ int l = !i ? s : c[i - 1] + 1, r = c[i]; if(t >= l && t <= r) return c[i]; } return c.back(); } else{ for(int i = 1; i < sz; i++){ int l = c[i], r = (i == sz - 1 ? s - 1: c[i + 1] - 1); if(t >= l && t <= r) return c[i]; } return c[0]; } }
#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...