Skip to content

Instantly share code, notes, and snippets.

@kuoe0
Created December 8, 2011 17:55
Show Gist options
  • Save kuoe0/1447824 to your computer and use it in GitHub Desktop.
Save kuoe0/1447824 to your computer and use it in GitHub Desktop.
bool DFS( int now, int cnt ) {
visit[ now ] = 1;
bool ret = 0;
if ( now == tgA )
ret = BFS( 1 );
if ( !cnt || ret ) {
visit[ now ] = 0;
return ret;
}
for ( int i = 0; i < 2; ++i ) {
int next = vertex[ now ][ i ];
if ( !visit[ next ] && DFS( next, cnt - 1 ) )
return 1;
}
visit[ now ] = 0;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment