이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
const int Nax = 1005;
class Undirected_Graph{
public:
int N, Timer = 0;
vector<vector<int>>adj;
vector<int>in, out;
Undirected_Graph(int _N):N(_N){
adj.resize(N);
out.resize(N);
in.resize(N);
}
inline void Add_Edge(int A, int B){
adj[A].push_back(B);
adj[B].push_back(A);
}
inline void Depth_First_Search(int Node, int Parent, int even = 1){
if (even)in[Node]=Timer++;
for (int& Next : adj[Node]){
if (Next == Parent)continue;
Depth_First_Search(Next,Node,even^1);
}
if (!even)in[Node]=Timer++;
}
};
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
std::vector<int> labels(n);
Undirected_Graph G(n);
for (int i = 0; i < n - 1; i++){
G.Add_Edge(u[i],v[i]);
}
G.Depth_First_Search(0,0);
labels = G.in;
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
for (int i = 0; i < (int)c.size(); i++){
if (t >= min(c[i],s) && t <= max(c[i],s))return c[i];
}
if (c.back() < s)return c[0];
else return c.back();
}
# | 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... |