# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1223635 | Ludissey | Stations (IOI20_stations) | C++20 | 307 ms | 576 KiB |
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define sz(a) (int)a.size()
#define all(a) (a.begin(), a.end())
vector<vector<int>> neigh;
vector<int> labels;
int tim=0;
void dfs(int x,int p){
for (auto u : neigh[x])
{
if(u==p) continue;
dfs(u,x);
}
labels[x]=tim++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
labels.clear();
neigh.clear();
labels.resize(n);
neigh.resize(n);
tim=0;
for (int i = 0; i < n-1; i++)
{
neigh[u[i]].push_back(v[i]);
neigh[v[i]].push_back(u[i]);
}
dfs(0,-1);
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
for (int i=0; i< sz(c); i++)
{
int u=c[i];
if(t>=s&&t>=u) return u;
if(t<=s&&t<=u) return u;
}
}
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... |