ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1145. Rope in the Labyrinth

Help me!
Posted by AXIS 5 Feb 2007 23:44
I always got Stack Overflow on test 6, help!

[code deleted]

Edited by moderator 13.02.2007 20:52
Re: Help me!
Posted by dimozzz 6 Feb 2007 00:28
I don't remeber...
Add this text in your program, before {APPTYPE CONSOLE}

{$MAXSTACKSIZE $10000000}

This number it is your stack size.
Re: Help me!
Posted by Nechaev Ilya (Rybinsk SAAT) 6 Feb 2007 00:35
Don't use DFS  :-)
Re: Help me!
Posted by AXIS 6 Feb 2007 23:12
Thanks)

Stack size don't work, i tried.

P.S. How to BFS?)
Re: Help me!
Posted by KIRILL(ArcSTU) 6 Feb 2007 23:31
AXIS wrote 6 February 2007 23:12
Thanks)

Stack size don't work, i tried.

)

Whats the problem??

{$M 16000000}  //From FAQ
Re: Help me!
Posted by AXIS 6 Feb 2007 23:47
It's a kind of magic)

i've forgotten Pascal completely...
MaxStackSize - this is Delphi code...

Now, it's WA6=)
Re: Help me!
Posted by AXIS 7 Feb 2007 00:08
This problem gonna take my brain...

Why WA???
Re: Help me!
Posted by KIRILL(ArcSTU) 7 Feb 2007 00:15
AXIS wrote 6 February 2007 23:47
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

Re: Help me!
Posted by AXIS 7 Feb 2007 00:35
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)
Re: Help me!
Posted by Nechaev Ilya (Rybinsk SAAT) 7 Feb 2007 16:52
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.
Re: Help me!
Posted by AXIS 7 Feb 2007 20:10
AC finally..

But i don't understand, why dfs solve doesn't work
Re: Help me!
Posted by KIRILL(ArcSTU) 7 Feb 2007 22:17
AXIS wrote 7 February 2007 20:10
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
Re: Help me!
Posted by AlexF [USTU] 8 Feb 2007 00:00
Just 2 waves. I had WA#6, when I used short int instead of int for my lenght variable.
Re: Help me!
Posted by [RSU_Tash]Shavkat_Khusanov 1 Jan 2011 16:11
Thanks
{$M 16000000}
helped me.
finaly AC with 0.046s, but 10Mb memory.
I used simple recursion.