# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
305712 | peti1234 | Stations (IOI20_stations) | C++17 | 1154 ms | 1232 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "stations.h"
using namespace std;
const int c=1002;
vector<int> sz[c], sol;
bool v[c];
int cnt;
void dfs(int a, bool b) {
v[a]=1;
if (!b) sol[a]=cnt++;
for (int i=0; i<sz[a].size(); i++) {
int x=sz[a][i];
if (!v[x]) dfs(x, !b);
}
if (b) sol[a]=cnt++;
}
vector<int> label(int n, int k, vector<int> x, vector<int> y) {
for (int i=0; i<n; i++) sz[i].clear(), v[i]=0, cnt=0, sol.clear();
sol.resize(n);
for (int i=0; i<n-1; i++) sz[x[i]].push_back(y[i]), sz[y[i]].push_back(x[i]);
dfs(0, 0);
return sol;
}
int find_next_station(int s, int t, vector<int> sz) {
int x=sz[0], y=sz.back(), si=sz.size();
if (s<x) {
if (t<s || t>y) return y;
for (int i=0; i<si; i++) if (sz[i]>=t) return sz[i];
}
if (t>s || t<x) return x;
for (int i=si-1; i>0; i--) if (sz[i]<=t) return sz[i];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |