#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int>graf[1010];
int pre[1010], it=-1, post[1010];
int dep[1010];
int czyost[1010];
void dfs(int x, int o){
dep[x] = dep[o]+1;
pre[x] = ++it;
if(graf[x].size())
czyost[graf[x].back()] = 1;
for(auto j: graf[x])
if(j!=o)
dfs(j, x);
if(czyost[x])it++;
post[x] = it;
}
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
int i;
dep[0] = 0;
for(i=0;i<n;i++)graf[i].clear();
for(i=0;i<n;i++)czyost[i] = 0;
for(i=0;i<n-1;i++){
graf[u[i]].push_back(v[i]);
graf[v[i]].push_back(u[i]);
}
it= -1;
dfs(0, 0);
std::vector<int> labels(n);
for (int i = 0; i < n; i++) {
if(dep[i]%2==1)
labels[i] = pre[i];
else labels[i] = post[i];
}
// for(i=0;i<n;i++)printf("%d: %d %d %d %d\n", i, dep[i], pre[i], post[i], labels[i]);
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(c.size()==1)return c[0];
int maxi=0;
for(auto j: c)
maxi = max(maxi, j);
if(s>=maxi){
// printf(" %d\n", s);
sort(c.begin(), c.end());
if(t>s)return c[0];
if(t<c[1])return c[0];
for(int i=1;i<(int)c.size();i++)
if(i==(int)c.size()-1 || c[i+1]>t)return c[i];
}
sort(c.begin(), c.end());
if(t<s){
return c.back();
}
if(s==0){
int pom = *lower_bound(c.begin(), c.end(), t);
return pom;
}
if(t>c[(int)c.size()-1])return c.back();
int pom = *lower_bound(c.begin(), c.end(), t);
return pom;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1738 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=2, label=1618 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
596 KB |
Invalid labels (duplicates values). scenario=1, label=1087 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
600 ms |
684 KB |
Output is correct |
2 |
Correct |
465 ms |
936 KB |
Output is correct |
3 |
Correct |
421 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
1 ms |
768 KB |
Output is correct |
6 |
Correct |
0 ms |
768 KB |
Output is correct |
7 |
Correct |
405 ms |
684 KB |
Output is correct |
8 |
Correct |
607 ms |
684 KB |
Output is correct |
9 |
Correct |
443 ms |
684 KB |
Output is correct |
10 |
Correct |
430 ms |
684 KB |
Output is correct |
11 |
Correct |
2 ms |
768 KB |
Output is correct |
12 |
Correct |
2 ms |
776 KB |
Output is correct |
13 |
Correct |
3 ms |
764 KB |
Output is correct |
14 |
Incorrect |
1 ms |
344 KB |
Invalid labels (duplicates values). scenario=3, label=6 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Invalid labels (duplicates values). scenario=1, label=1713 |
2 |
Halted |
0 ms |
0 KB |
- |