이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
#define pb emplace_back
using namespace std;
int lb[1005];
vector<int> conn[1005];
bool vi[1005];
int id = 0;
void dfs(int depth, int now) {
vi[now] = true;
if(depth % 2 == 0) {
lb[now] = id;
id++;
for(auto x: conn[now]) if(!vi[x]) dfs(depth + 1, x);
}
else {
for(auto x: conn[now]) if(!vi[x]) dfs(depth + 1, x);
lb[now] = id;
id++;
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
id = 0;
vector<int> labels(n);
for (int i = 0; i < n; i++) {
conn[i].clear();
vi[i] = false;
}
for(int i = 0; i < n - 1; i++) {
conn[u[i]].pb(v[i]);
conn[v[i]].pb(u[i]);
}
dfs(0, 0);
for(int i = 0; i < n; i++) {
labels[i] = lb[i];
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if(c.size() == 1) return c[0];
if(s < c[0]) {
if(t < s || t >= c[c.size() - 1]) {
return c[c.size() - 1];
}
int a = 0;
while(c[a] < t) a++;
return c[a];
}
else{
if(t > s || t <= c[0]) {
return c[0];
}
int a = c.size() - 1;
while(c[a] > t) a--;
return c[a];
}
}
# | 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... |