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;
typedef long long ll;
bool visited[1001];
vector<int> a, adj[1001];
int curr;
void dfs(int x=0) {
visited[x]=1;
a[x]=curr++;
for(auto i: adj[x]) if(!visited[i]) dfs(i);
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
curr=0;
a.resize(n);
memset(visited, 0, sizeof(visited));
for(int i=0; i<1001; i++) adj[i].clear();
for(int i=0; i<n-1; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs();
return a;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(t<=c[0]) return c[0];
return c[upper_bound(c.begin(), c.end(), t)-c.begin()-1];
}
# | 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... |