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 <bits/stdc++.h>
// #include "stations.h"
using namespace std;
vector<int> ans, g[1000];
vector<int> label(int n, int k, vector<int> u, vector<int> v){
ans.resize(n);
for (int i = 0; i < n; i ++) g[i].clear();
for (int i = 0; i < n - 1; i ++){
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
int l = 0;
for (int i = 0; i < n; i ++)
if (g[i].size() == 1)
l = i;
int cur = 0, p = -1;
for (int i = l; 1; ){
ans[i] = cur;
cur++;
if (g[i].size() == 1){
if (g[i][0] == p) break;
p = i;
i = g[i][0];
}
else{
if (g[i][0] == p){
p = i;
i = g[i][1];
}
else{
p = i;
i = g[i][0];
}
}
}
return ans;
}
int find_next_station(int s, int t, vector<int> c){
for (int x : c){
if (x < s and t < s) return x;
if (x > s and t > s) return x;
}
}
// int main(){
// int t;
// cin >> t;
// while (t--){
// int n, k;
// cin >> n >> k;
// vector<int> u(n - 1), v(n - 1);
// for (int i = 0; i < n - 1; i ++)
// cin >> u[i] >> v[i];
// label(n, k, u, v);
// for (int i = 0; i < n; i ++){
// for (int j = 0; j < n; j ++){
// if (i == j) continue;
// vector<int> adj;
// for (int x : g[i])
// adj.push_back(val[x]);
// sort(adj.begin(), adj.end());
// int res = find_next_station(val[i], val[j], adj);
// cout << val[i] << " -- " << val[j] << " == " << res << endl;
// }
// }
// }
// }
Compilation message (stderr)
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:49:1: warning: control reaches end of non-void function [-Wreturn-type]
49 | }
| ^
# | 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... |