# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
802636 | I_Love_EliskaM_ | Stations (IOI20_stations) | C++14 | 3 ms | 664 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;
#define forn(i,n) for(int i=0;i<n;++i)
#define pb push_back
#define all(x) x.begin(), x.end()
using ll = long long;
const int N=1e3;
int l[N], r[N];
vector<int> adj[N];
int nxt=0;
void dfs(int u, int p) {
l[u]=r[u]=nxt++;
for(auto&v:adj[u]) {
if (v==p) continue;
dfs(v,u);
r[u]=max(r[u],r[v]);
}
}
vector<int> label(int n, int k, vector<int>u, vector<int> v) {
forn(i,n) adj[i].clear(); nxt=0;
forn(i,n-1) {
adj[u[i]].pb(v[i]);
adj[v[i]].pb(u[i]);
}
dfs(0,-1);
vector<int> ans(n);
forn(i,n) ans[i]=l[i];
return ans;
}
int is_ancestor(int x, int y) {
//x is anc of y
return x < y;
}
int find_next_station(int s, int t, vector<int> adj) {
if (is_ancestor(s,t)) {
for(auto&v:adj) {
if (is_ancestor(v,s)) continue;
if (is_ancestor(v,t)) return v;
}
} else {
for(auto&v:adj) {
if (is_ancestor(v,s)) return v;
}
}
exit(1);
}
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... |