#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> ipii;
const int MAXN = 1e3+10;
const int MAX = 1e3;
int n, k;
vector <int> adj[MAXN], dw[MAXN];
vector <int> lab;
int cnt;
void dfs(int nw, int par, int dep){ // build val, tergantung dfs
if(dep%2 == 0) lab[nw] = cnt++;
for(auto nx : adj[nw]){
if(nx == par) continue;
dfs(nx, nw, dep+1);
}
if(dep%2) lab[nw] = cnt++;
}
vector<int> label(int N, int K, vector<int> u, vector<int> v) {
n = N; k = K;
lab.clear(); lab.resize(n); cnt = 0;
for(int i=0; i<=n; i++){
adj[i].clear(); dw[i].clear();
}
for(int i=0; i<n-1; i++){
adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]);
}
dfs(0, -1, 0);
for(int i=0; i<n; i++) cout << i << ' '<< lab[i] << " p\n";
return lab;
}
int find_next_station(int s, int t, vector<int> c) { // c sorted
if(s < c[0]){ // dep[s] = 0
if(t<s || t>=c.back()) return c.back(); // parent --> max
return *lower_bound(c.begin(), c.end(), t);
}
if(t>s || t<=c.front()) return c.front();
auto it = lower_bound(c.begin(), c.end(), t);
it--;
return *(it);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
488 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
552 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
488 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
492 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
484 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |