#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int dydis = 1000;
vector<int> gr[dydis];
int enter[dydis];
int leave[dydis];
vector<int> ret (dydis);
int dbInd = 0;
void dfs(int v, int came, int h = 0){
enter[v] = dbInd++;
for(auto x : gr[v]){
if(x == came) continue;
dfs(x, v, h+1);
}
leave[v] = dbInd++;
//cout << v << ": " << enter[v] << ", " << leave[v] << ", o dedu ";
if(h & 1){
ret[v] = leave[v];
cout << leave[v] << endl;
}else{
ret[v] = enter[v];
cout << enter[v] << endl;
}
//cout << "enter " << v << " - " << enter[v] << ", o leave " << leave[v]-1 << endl;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for(int i = 0; i < n; i++){
gr[i].clear();
gr[i].clear();
}
dbInd = 0;
ret.resize(n);
for(int i = 0; i < n-1; i++){
gr[u[i]].push_back(v[i]);
gr[v[i]].push_back(u[i]);
}
dfs(0, -1);
return ret;
}
int find_next_station(int s, int t, vector<int> c) {
bool yraMaz = 1;
for(auto x : c){
if(x < s) yraMaz = 0;
}
//cout << "gaunu " << s << ": "; for(auto x : c) cout << x<< " "; cout << "| ";
if(yraMaz){ // as enter
int dd = c.back();
int last = s;
//cout << "jis yra enter" << endl;
for(auto x : c){
if(x == dd && s != 0) continue;
int enter = last+1;
int leave = x;
if(enter <= t && t <= leave) return x;
last = leave;
}
return c.back();
}else{ // as leave
//cout << "jis yra leave" << endl;
for(int i = 1; i < (int)c.size(); i++){
int enter = c[i];
int leave = (i == (int)c.size() -1 ? s - 1 : c[i+1] - 1);
if(enter <= t && t <= leave){
return c[i];
}
}
return c[0];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
200 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
296 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
328 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
300 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
200 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |