# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1024351 | Ahmed_Solyman | Stations (IOI20_stations) | C++14 | 629 ms | 940 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>
using namespace std;
#include "stations.h"
#define loop(x, i) for (int i = 0; i < x; i++)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef set<int> si;
typedef vector<vi> vvi;
vvi adj;
vi nrs;
void DFS(int i, int prev = -1, int nr = 0)
{
if (nr > 1000)
throw;
nrs[i] = nr;
for (int j : adj[i])
{
if (prev == j)
continue;
DFS(j, i, nr + 1);
}
}
vi label(int n, int k, vi u, vi v)
{
nrs = vi(n);
adj = vvi(n);
loop(u.size(), i)
{
adj[u[i]].pb(v[i]);
adj[v[i]].pb(u[i]);
}
int start = 0;
loop(n, i)
{
if (adj[i].size() == 1)
{
start = i;
break;
}
}
DFS(start);
return nrs;
}
int find_next_station(int s, int t, vi c)
{
if (c.size() == 1)
return c[0];
for (int l : c)
if (l == t)
return t;
if (t > s)
return c.back();
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... |