| 
 | 
back to boardI always got Stack Overflow on test 6, help!   [code deleted]   Edited by moderator 13.02.2007 20:52 I don't remeber... Add this text in your program, before {APPTYPE CONSOLE}   {$MAXSTACKSIZE $10000000}   This number it is your stack size. Don't use DFS  :-) Thanks)   Stack size don't work, i tried.   P.S. How to BFS?) Thanks)   Stack size don't work, i tried.   )  Whats the problem??  {$M 16000000}  //From FAQ It's a kind of magic)   i've forgotten Pascal completely... MaxStackSize - this is Delphi code...   Now, it's WA6=) This problem gonna take my brain...   Why WA??? It's a kind of magic)   i've forgotten Pascal completely... MaxStackSize - this is Delphi code...   Now, it's WA6=)  The $MINSTACKSIZE and $MAXSTACKSIZE directives are used in Windows programming only.  As I know 2 DFS is needed for this problem   I've written two BFS - WA6.   My idea in this code - finding in the vertex V the furthest vertexes, that they are in different subtrees in tree with root V.   Something like that, hard to explain) First BFS - finding the free cell A that is the furthest from some free cell. Second BFS - finding the free cell B that is the furthest from cell A. AC finally..   But i don't understand, why dfs solve doesn't work AC finally..   But i don't understand, why dfs solve doesn't work  I've solved it with dfs It's very simple and fast If you want I can send my solution to you Just 2 waves. I had WA#6, when I used short int instead of int for my lenght variable. Thanks {$M 16000000} helped me. finaly AC with 0.046s, but 10Mb memory. I used simple recursion.  |  
  | 
|