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;
vi label(int n, int k, vi u, vi v)
{
vi labels(n);
for (int i = 0; i < n; i++)
{
labels[i] = i;
}
return labels;
}
int DFS(int i, int t, vvi &adj, int prev = -1)
{
for (int j : adj[i])
{
if (j == prev)
continue;
if (j == t)
return j;
int ans = DFS(j, t, adj, i);
if (ans != -1)
return j;
}
return -1;
}
int find_next_station(int s, int t, vi c)
{
// int n = max(s, t) + 1;
int n = 1000;
vvi adj(n);
loop(n - 1, i)
{
adj[i + 1].pb(i / 2);
adj[i / 2].pb(i + 1);
}
return DFS(s, t, adj);
}
# | 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... |