# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
431961 | Ozy | Stations (IOI20_stations) | C++17 | 920 ms | 784 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 "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define MAX 1000
lli act,ini,fin;
vector<lli> hijos[MAX+2];
vector<int> res;
void DFS (lli pos, lli padre, lli prof) {
if ((prof%2) == 0) res[pos] = act++;
for (auto h : hijos[pos]) {
if (h == padre) continue;
DFS(h,pos,prof+1);
}
if ((prof%2) == 1) res[pos] = act++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
rep(i,0,n-1) hijos[i].clear();
vector<int>().swap(res);
res.resize(n);
rep(i,0,n-2) {
hijos[u[i]].push_back(v[i]);
hijos[v[i]].push_back(u[i]);
}
act = 0;
DFS(0,0,0);
return res;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (c.size() == 1) return c[0];
if (s == 0) rep (i,0,c.size()-1) if (t <= c[i]) return c[i];
if (s < c[0]) {
ini = s;
fin = c[c.size()-2];
if (t < ini || t > fin) return c[c.size()-1];
rep (i,0,c.size()-2) if (t <= c[i]) return c[i];
}
else {
ini = c[1];
fin = s;
if (t < ini || t > fin) return c[0];
repa (i,c.size()-1,1) if (t >= c[i]) return c[i];
}
return c[0];
}
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... |