Submission #621859

#TimeUsernameProblemLanguageResultExecution timeMemory
6218598e7Stations (IOI20_stations)C++17
100 / 100
1079 ms860 KiB
//Challenge: Accepted #include <bits/stdc++.h> using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r){ while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 1000 #define pii pair<int, int> #define ff first #define ss second #include "stations.h" const int mul = 501; vector<int> adj[maxn]; int mark[maxn]; int ti; int dep[maxn]; void dfs(int n, int par, int d) { dep[n] = d; if (d % 2 == 0) mark[n] = ti++; for (int v:adj[n]) { if (v != par) { dfs(v, n, d+1); } } if (d % 2) mark[n] = ti++; } std::vector<int> label(int n, int LIM, std::vector<int> U, std::vector<int> V) { vector<int> ret(n); for (int i = 0;i < n;i++) { adj[i].clear(); mark[i] = 0; } ti = 0; for (int i = 0;i < n - 1;i++) { adj[U[i]].push_back(V[i]); adj[V[i]].push_back(U[i]); } dfs(0, -1, 0); for (int i = 0;i < n;i++) ret[i] = mark[i]; return ret; } const int inf = 1e9; int find_next_station(int s, int t, std::vector<int> c) { sort(c.begin(), c.end()); bool in = 1; for (int v:c) { if (s > v) in = 0; } if (in) { if (t < s) return c.back(); for (int v:c) { if (t <= v) return v; } return c.back(); } else { if (t > s) return c[0]; for (int i = (int)c.size() - 1;i >= 0;i--) { int v = c[i]; if (t >= v) return v; } return c[0]; } return 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...