# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
592529 | PiejanVDC | Stations (IOI20_stations) | C++17 | 3038 ms | 2097152 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;
vector<int>adj[1005];
vector<int>l;
int curr = 0;
void dfs(int u, bool f, int e = -1) {
if(f)
l[u] = curr++;
for(auto z : adj[u]) if(z != e) {
dfs(z, 1 - f, u);
}
if(!f)
l[u] = curr++;
}
vector<int>label(int n, int k, vector<int>u, vector<int>v) {
l.resize(n, -1);
curr = 0;
for(int i = 0 ; i < (int)u.size() ; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0, 1);
return l;
}
int find_next_station(int s, int t, vector<int>c) {
if(c.size() == 1)
return c[0];
if(s < c[0]) {
if(t < s)
return c.back();
if(t >= c.back())
return c.back();
for(int i = 0 ; i < c.size()-1 ; i++)
if(c[i] >= t)
return c[i];
} else {
if(t > s)
return c[0];
if(t <= c[0])
return c[0];
for(int i = 1 ; i < c.size() ; i++)
if(c[i] <= t)
return c[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... |