# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
795885 | BT21tata | Stations (IOI20_stations) | C++17 | 780 ms | 848 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;
int cur;
vector<int> g[1005], labels;
void dfs(int v, int p, int x)
{
if(!x) labels[v]=cur++;
for(int u : g[v])
{
if(u==p) continue;
dfs(u, v, x^1);
}
if(x) labels[v]=cur++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
labels.resize(n, 0);
for(int i=0; i<n; i++)
g[i].clear();
cur=0;
for(int i=0; i<u.size(); i++)
{
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
dfs(0, -1, 0);
/*for(int u :labels)
cout<<u<<' ';
cout<<flush;*/
return labels;
}
int find_next_station(int s, int t, vector<int> c)
{
sort(c.begin(), c.end());
if(s<c[0])
{
int fs=s;
for(int i=0; i<c.size()-1; i++)
{
if(fs<=t and t<=c[i]) return c[i];
fs=c[i]+1;
}
return c.back();
}
else
{
int last=s;
for(int i=c.size()-1; i>0; i--)
{
if(c[i]<=t and t<=last) return c[i];
last=c[i]-1;
}
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... |