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;
const int N = 1010;
vector<int> g[N];
int tin[N], tout[N], dp[N];
int tim=0, tim2=0;
void dfs(int at, int p) {
// if(dp[at])
tin[at]=tim++;
for(int to:g[at])
{
if(to==p)continue;
dp[to] = dp[at]^1;
dfs(to, at);
}
// if(!dp[at])
// tout[at]=tim++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
std::vector<int> labels(n);
for(int i = 0;i<=n;i++)g[i].clear();
tim=0;
for(int i = 0;i<n-1;i++) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
for(int i = 0;i<n;i++) {
if(g[i].size()==1) {
dfs(i,i);
break;
}
}
for (int i = 0; i < n; i++) {
labels[i] = tin[i];
// if(dp[i])labels[i] = tin[i];
// else labels[i] = tout[i];
// cout << i << " " << labels[i] << endl;
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
vector<int> kk=c;
sort(kk.begin(), kk.end());
if(s < t)return kk.back();
else return kk[0];
return 0;
}
# | 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... |