| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 433039 | Ruba_K | Stations (IOI20_stations) | C++14 | 3030 ms | 2097156 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 <vector>
#include<bits/stdc++.h>
using namespace std ;
const int N = 1e3 + 3 ;
vector<int> labels;
vector<int> adj[N];
int getlog(int i){
return log2(i + 1);
}
int st = 0 ;
void dfs(int u , int p , int l){
if(st != u)
labels[u] = l ;
else labels[u] = 0 ;
for(int i = 0 ; i < adj[u].size() ; i ++){
auto f = adj[u][i];
if(f != p){
if(u == st)dfs(f , u , 1e3 * (i + 1));
else dfs(f , u , l + 1);
}
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
labels.resize(n);
// clear
for(int i = 0 ; i < n - 1 ; 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() > 2)st = i ;
dfs(st , -1 , 0);
return labels;
}
int find_next_station(int s, int t,vector<int> c) {
if(s / 1e3 == t / 1e3){
if(s > t)return s - 1 ;
else return s + 1 ;
}
else if(s == 0)return (t / 1000) * 1000 ;
else return(s % 1000 == 0 ? 0 : s - 1);
return c[0];
}
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... | ||||
