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;
vector<int>a[5001];
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
int cnt[5001];
for(int i=0;i<n;i++){a[i].clear();cnt[i]=0;}
for(int i=0;i<n-1;i++) {
a[u[i]].push_back(v[i]);
a[v[i]].push_back(u[i]);
cnt[u[i]]++;
cnt[v[i]]++;
}
int c=0;
for(int i=0;i<n;i++) {
if(cnt[i]==1)c=i;
}
vector<int>ans(n,0);
vector<int>used(n,0);
for(int i=0;i<n;i++) {
used[c]=1;
ans[c]=i;
for(int j:a[c]) {
if(used[j]==0) {
used[j]=1;
c=j;
break;
}
}
}
return ans;
}
int find_next_station(int s, int t, vector<int> c) {
sort(c.begin(),c.end());
if(c.size()==1)return c[0];
if(t>s)return c[1];
else return c[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... |