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 "stations.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll it = 1;
void dfs(ll node, vector<vector<ll>> & adj, vector<bool> & vis, vector<int> & labels){
vis[node] = 1;
labels[node] = it;
//cout << node << "\n";
for(auto x : adj[node]){
if(vis[x]) continue;
it++;
dfs(x, adj, vis, labels);
}
}
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vector<int> labels(n);
vector<vector<ll>> adj(n);
for(int i = 0; i < (ll)u.size(); i++){
adj[ u[i] ].push_back( v[i] );
adj[ v[i] ].push_back( u[i] );
}
for(int i = 0; i < n; i++){
if(adj[i].size() == 1){
vector<bool> vis(n);
dfs( i, adj, vis, labels);
break;
}
}
for(auto x : labels) cout << x << " ";
cout << "\n";
return labels;
}
int find_next_station(int s, int t, std::vector<int> c){
sort(c.begin(), c.end());
if(t > s && s != 0){
return c[1];
}
return c[0];
}
# | 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... |