Submission #535062

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
5350622022-03-09 10:56:23chenwzStations (IOI20_stations)C++14
100 / 100
1091 ms676 KiB
#include "stations.h"
#include <vector>
#include <algorithm>
using namespace std;
typedef vector<int> VI;
void dfs(int u, int fa, bool dfs_in, int &clock, const vector<VI>& G, VI& L) {
if (dfs_in) L[u] = clock++;
for (int i : G[u])
if (i != fa) dfs(i, u, !dfs_in, clock, G, L);
if (!dfs_in) L[u] = clock++;
}
VI label(int n, int k, VI u, VI v) {
VI L(n);
vector<VI> G(n, VI());
for (size_t i = 0; i < u.size(); i++)
G[u[i]].push_back(v[i]), G[v[i]].push_back(u[i]);
int clock = 0;
dfs(0, -1, true, clock, G, L);
return L;
}
int find_next_station(int s, int t, VI c) {
int c0 = c[0];
if (c0 > s) { // Case 1: s is Tin. All the neighbors' label > s.
if (t < s || t > c.back()) return c.back(); // t not in this subtree, go to parent.
return *lower_bound(c.begin(), c.end(), t); // t is in this subtree, Pick the smallest ch >= t
}
// Case 2: s is Tout level.
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...