Created
December 8, 2011 17:55
-
-
Save kuoe0/1447824 to your computer and use it in GitHub Desktop.
d151 - Break Up is Hard to Do (http://140.122.185.166/ZeroJudge/ShowProblem?problemid=d151)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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