이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 != 1){
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... |