Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <string>
- #include <cstring>
- #include <vector>
- #define TAM 110
- using namespace std;
- vector<int> g[ TAM ] ;
- bool v[ TAM ] ;
- vector<int> tp ;
- void init(){
- for(int i = 0 ; i < TAM ; i++) g[ i ] .clear() ;
- memset( v, 0 , sizeof v ) ;
- tp.clear() ;
- }
- void dfs( int x ){
- v[ x ] = true ;
- for(int i = 0 ; i < g[ x ] .size() ; i++){
- int u = g[ x ][ i ] ;
- if( v[ u ] ) continue ;
- dfs( u ) ;
- }
- tp.push_back( x+1 ) ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement