Submission #579445

#TimeUsernameProblemLanguageResultExecution timeMemory
579445pirhosigStations (IOI20_stations)C++17
0 / 100
752 ms676 KiB
#include "stations.h" #include <bits/stdc++.h> #define R(a) for (int i = 0; i < a; ++i) #define RR(a) for (int j = 0; j < a; ++j) using namespace std; void name(vector<int> adj[], vector<int>& val, int& cont, bool even, int p, int n) { if (!even) val[n] = cont++; for (int a : adj[n]) { if (a != p) name(adj, val, cont, !even, n, a); } if (even) val[n] = cont++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> adj[n]; R(n - 1) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } vector<int> labels(n); int cont = 0; name(adj, labels, cont, false, -1, 0); return labels; } int find_next_station(int s, int t, vector<int> c) { if (s == 0) { for (int a : c) { if (a >= t) return a; } } else { int m = c.size(); bool yea = true; for (int a : c) { if (a > t) { yea = false; break; } } if (yea) { if (c[0] + 1 <= t && t <= s) { for (int i = 1; i < m - 1; ++i) { if (t < c[i + 1]) return c[i]; } return c[m - 1]; } else return c[0]; } else { if (s < t && t < c[m - 1]) { R(m - 1) { if (t <= c[i]) return c[i]; } } return c[m - 1]; } } return -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...