#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int>graf[1010];
int pre[1010], it=-1, post[1010];
int dep[1010];
void dfs(int x, int o){
dep[x] = dep[o]+1;
pre[x] = ++it;
for(auto j: graf[x])
if(j!=o)
dfs(j, x);
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-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];
}
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);
bool czy=0;
if(s>=maxi){
s = 2001-s;
t = 2001-s;
for(auto &j: c)j = 2001-j;
czy = 1;
}
sort(c.begin(), c.end());
if(t<s){
if(czy)c.back()=2001-c.back();
return c.back();
}
if(s==0){
int pom = *lower_bound(c.begin(), c.end(), t);
if(pom)pom=2001-pom;
return pom;
}
if(t>c[(int)c.size()-1])return c.back();
int pom = *lower_bound(c.begin(), c.end(), t);
if(pom)pom=2001-pom;
return pom;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
520 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
359 ms |
944 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
668 ms |
684 KB |
Output is correct |
2 |
Incorrect |
450 ms |
684 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
330 ms |
688 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |