# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
305244 | oscarsierra12 | Stations (IOI20_stations) | C++14 | 4 ms | 760 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 = 1010 ;
int dfsNum[N];
int cnt = 0 ;
vector <int> G[N] ;
int dfs ( int u, int p, int f ) {
if ( f ) dfsNum[u] = cnt++ ;
for ( auto v:G[u] ) if ( v!=p ) dfs (v, u, 1-f) ;
if ( !f ) dfsNum[u] = cnt++ ;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
std::vector<int> labels(n);
for ( int i = 0 ; i < n ; ++i ) G[i].clear() ;
cnt = 0 ;
for ( int i = 0 ; i + 1 < n ; ++i ) {
G[u[i]].push_back ( v[i] ) ;
G[v[i]].push_back ( u[i] ) ;
}
dfs ( 0, -1, 0 ) ;
for (int i = 0; i < n; i++) {
labels[i] = dfsNum[i];
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
sort ( c.begin(), c.end() ) ;
if ( c[0] > s ) {
///s is timein
if ( t < s ) return c.back() ;
for ( auto i:c )
if ( i >= t ) return i ;
return -1 ;
}
///s is timeout
if ( s < t ) return c[0] ;
for ( int i = 1 ; i < c.size() ; ++i )
if ( c[i] > t ) return c[i-1] ;
return c.back();
}
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... |