# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
403160 | AmineTrabelsi | Stations (IOI20_stations) | C++14 | 1126 ms | 620 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;
const int Mx = 1010;
void dfs(int node,int par,vector<int> &labels,vector<vector<int>> &tr){
for(auto i:tr[node]){
if(i != par){
labels[i] = labels[node]+1;
dfs(i,node,labels,tr);
}
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> labels(n);
vector<vector<int>> tr(n+1,vector<int>(0));
for (int i = 0; i < n-1; i++) {
tr[u[i]].push_back(v[i]);
tr[v[i]].push_back(u[i]);
}
int root = 0;
for(int i=0;i<n;i++){
if(tr[i].size() == 1){
root = i;
break;
}
}
dfs(root,-1,labels,tr);
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if(t <= s)
return *min_element(c.begin(),c.end());
return *max_element(c.begin(),c.end());
}
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... |