#include<bits/stdc++.h>
using namespace std ;
#define maxn 200009
#define ll long long
#define pb push_back
#define fi first
#define se second
#define left id<<1
#define right id<<1|1
#define re exit(0);
#define _lower(x) lower_bound(v.begin(),v.end(),x)-v.begin()+1
#define TIME ( 1.0*clock() / CLOCKS_PER_SEC )
const int mod = 1e9+7 ;
const int INF = 1e9 ;
typedef vector<int> vi ;
typedef pair<int,int> pii ;
typedef vector<pii> vii ;
template < typename T > void chkmin ( T &a , T b ) { if ( a > b ) a = b ; }
template < typename T > void chkmax ( T &a , T b ) { if ( a < b ) a = b ; }
void add ( int &a , int b )
{
a += b ;
if ( a >= mod ) a -= mod ;
if ( a < 0 ) a += mod ;
}
void rf ()
{
freopen ("bai1.inp","r",stdin) ;
}
mt19937 rng (time(0)) ;
int _pow ( int a , int n )
{
if ( n == 0 ) return 1 ;
int res = _pow (a,n/2) ;
if ( n % 2 ) return 1ll*res*res%mod*a%mod ;
else return 1ll*res*res%mod ;
}
vi label ( int n , int k , vi u , vi v ) ;
int find_next_station ( int source , int target , vi list ) ;
int n , k ;
vi adjList [maxn] ;
vi Label ;
int inTime,outTime ;
int tin [maxn] , tout [maxn] ;
void dfs ( int u , int par = -1 )
{
tin [u] = inTime ++ ;
for ( auto v : adjList [u] )
{
if ( v == par ) continue ;
dfs (v,u) ;
}
tout [u] = outTime ++ ;
}
void reset ()
{
inTime = outTime = 0 ; Label . assign (n,0) ;
for ( int i = 0 ; i < n ; i ++ ) adjList [i] . clear () ;
}
bool child ( int x , int y )
{
int tin_y = y / 1000 , tout_y = y % 1000 ;
int tin_x = x / 1000 ;
if ( tin_x >= tin_y && tin_x <= tout_y ) return true ;
return false ;
}
vi label ( int N , int K , vi U , vi V )
{
n = N , k = K ;
reset () ;
for ( int i = 0 ; i < U.size () ; i ++ )
{
int u = U [i] , v = V [i] ;
adjList [u] . pb (v) ;
adjList [v] . pb (u) ;
}
dfs (0) ;
for ( int i = 0 ; i < n ; i ++ ) Label [i] = (tin[i]*1000+tout[i]) ;
return Label ;
}
const int P = 1000 ;
bool inside(int a, int b) {
return a / P <= b / P && b % P <= a % P;
}
int find_next_station(int s, int t, vi c) {
sort (c.begin(),c.end()) ;
for (int node : c)
if (inside (s,node) && inside(node, t))
return node;
return c[0];
}
//int main ()
//{
// ios_base::sync_with_stdio(0);
// cin.tie(0);cout.tie(0);
//// rf () ;
// vi answer_Label = label(5, 10, {0, 1, 1, 2}, {1, 2, 3, 4}) ;
// for ( auto x : answer_Label ) cout << x << " " ; cout << endl ;
// int source , target ; cin >> source >> target ;
// int source_x , target_x ;
// for ( int i = 0 ; i < answer_Label.size () ; i ++ )
// {
// if ( answer_Label [i] == source ) source_x = i ;
// if ( answer_Label [i] == target ) target_x = i ;
// }
// cout << "source target: " << source_x << " " << target_x << "\n" ;
// vi neigh ;
// for ( auto x : adjList[source_x] ) neigh . pb (answer_Label[x]) ;
// cout << find_next_station (source,target,neigh) ;
//}
Compilation message (stderr)
stations.cpp: In function 'void rf()':
stations.cpp:32:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
32 | freopen ("bai1.inp","r",stdin) ;
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# | 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... |