# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
306429 | 2020-09-25T14:46:54 Z | CaroLinda | Stations (IOI20_stations) | C++14 | 3000 ms | 2097156 KB |
#include "stations.h" #include <bits/stdc++.h> #define lp(i,a,b) for(int i = a; i < b; i++) #define debug //printf #define ff first #define ss second #define mk make_pair #define ll long long #define pii pair<int,int> #define all(x) x.begin(),x.end() #define sz(x) (int)(x.size()) const int MAXN = 1010 ; using namespace std ; int tin[MAXN] , tout[MAXN] ; vector<int> adj[MAXN] ; int currTime = -1 ; void dfs(int x, int father) { tin[x] = tout[x] = ++currTime ; for(auto e :adj[x]) { if(e == father) continue ; dfs(e,x) ; tout[x] = ++currTime ; } if( (tin[x]&1) != (tout[x]&1) ) tout[x] = ++currTime ; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { for(int i = 0 ; i <n-1 ; i++ ) { adj[ u[i] ].push_back(v[i]) ; adj[v[i]].push_back(u[i]) ; } dfs(0,-1) ; vector<int> labels(n) ; for(int i = 0 ; i < n ; i++ ) { if(tin[i]&1) labels[i] = tin[i] ; else labels[i] = tout[i] ; } lp(i,0,n) debug("%d %d\n" , i , labels[i]) ; return labels ; } int find_next_station(int s, int t, std::vector<int> c) { for(auto e: c ) if(e == t) return t ; if( c[0]&1 ) { //ou seja, tenho os tin's if(t > s ) return c[0] ; for(int i = sz(c) - 1 ; i>= 0 ; i-- ) if( c[i] < t ) return c[i] ; return c[0] ; } else { //tenho os tout's if( t < s ) return c[ sz(c)-1 ] ; for(int i = 0 ; i < sz(c) ; i++ ) if( c[i] > t ) return c[i] ; return c[ sz(c)-1 ] ; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1611 ms | 2097156 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3042 ms | 628 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1772 ms | 2097156 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 937 ms | 872 KB | Output is correct |
2 | Runtime error | 1366 ms | 2097156 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3149 ms | 2097156 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |