Submission #306429

#TimeUsernameProblemLanguageResultExecution timeMemory
306429CaroLindaStations (IOI20_stations)C++14
0 / 100
3149 ms2097156 KiB
#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 (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:58:18: warning: left operand of comma operator has no effect [-Wunused-value]
   58 |  lp(i,0,n) debug("%d %d\n" , i , labels[i]) ;
      |                  ^~~~~~~~~
stations.cpp:58:42: warning: right operand of comma operator has no effect [-Wunused-value]
   58 |  lp(i,0,n) debug("%d %d\n" , i , labels[i]) ;
      |                                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...