851 - Maze
Moderator: Board moderators
851 - Maze
Do I need to walk UNTIL i reach a blocked location? or I can stop anywhere and continue to the next direction?
-
- Learning poster
- Posts: 63
- Joined: Thu Apr 04, 2002 2:00 am
-
- Learning poster
- Posts: 63
- Joined: Thu Apr 04, 2002 2:00 am
The locations which are considered as "escaped" are those you marked with "A":
Code: Select all
OOAO
A..O
OO.A
OAAO
Re: 851
For the input
north
north
south
a correct output should bechchan3 wrote: . . . . . .
. . .OO .
. . .OO .
.OOOO .
.O . . . .
. . . . . .
thx
north
north
south
851 Maze II
i cant imagine any other method except bute force search
but it takes too much time to pass the judge.
does anyone have a better solution ???
but it takes too much time to pass the judge.
does anyone have a better solution ???
mine is BFS, I'm using linked list to store information before processing, but I got memory limit
I've tried to count how many times I allocating memory and how many times I deallocating it, and they are the same.
the program runs very slow too, I just store the path, so I need to calculate everytime from the beginning. I use this method to save memory used, but still memory limit.

I've tried to count how many times I allocating memory and how many times I deallocating it, and they are the same.
the program runs very slow too, I just store the path, so I need to calculate everytime from the beginning. I use this method to save memory used, but still memory limit.
Hi everyone.
I suggest you solve this problem with A* search. It's easy to code, and it runs in reasonable time. (Mine runs for ~2 sec. How I wish I know IDA*...)
Hint: the number of moves required in the cases doesn't seem to exceed 30.
Have fun~
I suggest you solve this problem with A* search. It's easy to code, and it runs in reasonable time. (Mine runs for ~2 sec. How I wish I know IDA*...)
Hint: the number of moves required in the cases doesn't seem to exceed 30.

Have fun~

7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
851 Maze II
I suffered from getting WA.
However, I tried to generate some test data.
Hope someone to verify this.
--
DJWS, a newbie in programming
However, I tried to generate some test data.
Hope someone to verify this.

Code: Select all
20
5
OOOOO
O...O
O.OOO
O...O
OOO.O
5
OOOOO
O....
O.OOO
O...O
OOOOO
5
OOOOO
O....
OOOOO
....O
OOOOO
5
OOOOO
O...O
OO.OO
.....
OOOOO
5
O.O.O
O.O.O
.....
O.O.O
O.O.O
5
.....
.O.O.
.....
.O.O.
.....
5
.....
..OO.
.O...
.O...
.....
5
.....
.....
..O..
.....
.....
5
.....
.....
OOOOO
.....
.....
5
OO.OO
OO...
...OO
OO.OO
OO.OO
5
OOOOO
OOO..
...OO
OO.OO
OO.OO
5
OOOOO
OOO..
...OO
OO...
OOOOO
5
O.OOO
O.O..
OOOOO
..O.O
OOO.O
5
O.O.O
..O..
OOOOO
..O..
O.O.O
5
OOOOO
O...O
O...O
O...O
OOO.O
5
OOOOO
O...O
O...O
O...O
OO.OO
5
OOOOO
O...O
O...O
O...O
O...O
5
OOOOO
OOOOO
OOOOO
O...O
OO.OO
5
OOOOO
OOOOO
OOOOO
OOOOO
OOOOO
5
.....
.....
.....
.....
.....
DJWS, a newbie in programming
