# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
431395 | idk321 | Stations (IOI20_stations) | C++17 | 931 ms | 608 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;
const int M = 1000000000;
const int N = 1000;
int in[N];
int out[N];
vector<int> adj[N];
vector<int> labels;
int n, k;
int timer;
void dfs2(int node, int par)
{
timer++;
in[node] = timer;
for (int next : adj[node])
{
if (next == par) continue;
dfs2(next, node);
}
out[node] = timer;
}
void dfs(int node, int par, int num)
{
labels[node] = num;
for (int next : adj[node])
{
if (next == par) continue;
dfs(next, node, num + 1);
}
}
std::vector<int> label(int n1, int k1, std::vector<int> u, std::vector<int> v) {
n = n1;
k = k1;
labels.assign(n, 0);
for (int i = 0; i < n; i++) adj[i].clear();
for (int i = 0; i < u.size(); i++)
{
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
for (int i = 0; i < n; i++)
{
if (adj[i].size() == 1)
{
dfs(i, -1, 0);
break;
}
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (s < t)
{
for (int j : c)
{
if (j > s) return j;
}
} else
{
for (int j : c)
{
if (j < s) return j;
}
}
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... |