# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
307686 | CodePlatina | Stations (IOI20_stations) | C++14 | 912 ms | 1272 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 <vector>
using namespace std;
vector<int> gph[1010];
int ord[1010];
int cnt = 0;
void dfs(int x)
{
ord[x] = ++cnt;
for(auto y : gph[x]) if(!ord[y]) dfs(y);
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
vector<int> labels(n);
for(int i = 0; i < n; ++i) ord[i] = 0;
cnt = 0;
for(int i = 0; i < n - 1; ++i)
{
gph[u[i]].push_back(v[i]);
gph[v[i]].push_back(u[i]);
}
dfs(0);
for(int i = 0; i < n; ++i) labels[i] = ord[i];
return labels;
}
int find_next_station(int s, int t, vector<int> c)
{
int mn = (int)1e9, mn2 = (int)1e9;
for(int x : c)
{
if(mn2 > x) swap(x, mn2);
if(mn > mn2) swap(mn, mn2);
}
int n = (mn2 == (int)1e9 ? c[0] + 1 : mn2 - 1);
if(s <= n && n <= t)
{
for(int x : c) if(n <= x && x <= t) return x;
}
else return mn;
}
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... |