# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1067575 | guanex | Stations (IOI20_stations) | C++14 | 664 ms | 832 KiB |
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;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
std::vector<int> labels(n);
int ed[n];
vector<vector<int>> x(n);
for(int i = 0; i < n-1; ++i){
labels[i] = -1;
x[u[i]].push_back(v[i]);
x[v[i]].push_back(u[i]);
}
labels[n-1] = -1;
int root = 0;
for(int i = 0; i < n; ++i){
if((int)x[i].size() == 1){
root = i;
break;
}
}
queue<int> q;
q.push(root);
labels[root] = 0;
int num = 0;
while(!q.empty()){
int p = q.front();
q.pop();
for(auto e:x[p]){
if(labels[e] != -1){
continue;
}else{
q.push(e);
labels[e] = ++num;
}
}
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(s > t){
return s-1;
}else{
return s+1;
}
}
Compilation message (stderr)
# | 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... |