Page **1** of **2**

### 10582 - ASCII Labyrinth

Posted: **Mon Dec 22, 2003 1:13 pm**

by **titid_gede**

hi,

what is the output for :

Code: Select all

```
3
1 1
+---+
| |
| |
| |
+---+
1 1
+---+
| * |
| * |
| * |
+---+
2 2
+---+---+
| | |
| |** |
| | * |
+---+---+
| | |
| | |
| | |
+---+---+
```

thanks in advance

-titid-

Posted: **Thu Dec 25, 2003 2:16 pm**

by **Whinii F.**

My accepted solution outputs:

Number of solutions: 0

Number of solutions: 2

Number of solutions: 0

Which looks quite trivial

Posted: **Thu Dec 25, 2003 5:38 pm**

by **titid_gede**

thanks, got AC now.

### Help

Posted: **Thu Dec 25, 2003 6:04 pm**

by **domino**

Could someone please post some more testcases, as i cannot get accepted...

### Please help me

Posted: **Sun Dec 28, 2003 6:54 pm**

by **domino**

I have tried solving 10582 by backtracking, but i get wrong answer. Can somebody give me some hard testcases or a source code? Should i post my code?

Posted: **Tue Dec 30, 2003 9:00 pm**

by **Md. Sajjad Hossain**

shouldn't there be a special judge ?

Posted: **Wed Dec 31, 2003 2:49 am**

by **titid_gede**

hi,

to domino : i also use backtrack. i dont think there will be trickies input, except input i asked (in this thread) was confused me at first.

to mohd sajjad hossain : why do you think need special judge? i think it has unique result.

Posted: **Wed Dec 31, 2003 3:02 pm**

by **the LA-Z-BOy**

One tricky input could have been

where

**Number of solutions: 4** (or what else?).. but it is NOT present in the input data

.

btw. the second input given by

**titid_gede** isn't valid i think...

because as the problem states... all the patterns should be in the `initial' form where

there are exactly three valid initial patterns for a square.

happy new year

Posted: **Fri Apr 23, 2004 4:42 am**

by **Larry**

Posted: **Fri Apr 23, 2004 11:28 am**

by **the LA-Z-BOy**

I think it should be

**four**, because the

**number of solution** counts as

whether one can turn the pieces in such a way that the patterns form a line connecting **some** edge of the top left square and **some** edge of the bottom right square of the board.

so the four solutions would be...

Code: Select all

```
+---+
| * |
|** |
| |
+---+
+---+
| * |
| **|
| |
+---+
+---+
| |
|** |
| * |
+---+
+---+
| |
| **|
| * |
+---+
```

Note that the same square is the

**top left** and

**bottom right** square. And for each solution it satisfies the constrains that

**a line connects some edge of the top left square with some edge of bottom right square**. The solution would have been 2 if you assume the fact as "line connects top/left edge of top left square and bottom/right edge of the bottom square". But this is not stated in the problem statement i think.

thank you.

Posted: **Fri Apr 23, 2004 9:53 pm**

by **Larry**

Well, then we know such inputs don't exist, because that's what I assume.. =)

### 10582

Posted: **Sun Dec 11, 2005 7:27 am**

by **alzika**

How do I even attempt this problem? I know it is backtracking, and that part is rather easy, but I'm not sure how to handle the backtracking portion involving the rotations and keeping track, as well as finding the NUMBER of solutions instead of just finding if there is a path at all.

Any assitance or a nudge in the right direction is appreciated.

### Re: 10582

Posted: **Sun Dec 11, 2005 12:44 pm**

by **Martin Macko**

alzika wrote:How do I even attempt this problem? I know it is backtracking, and that part is rather easy, but I'm not sure how to handle the backtracking portion involving the rotations

In every step you can remember how you are rotated. There are four possible rotations. Let's denote them by numbers 0, 1, 2 and 3. After applying square A the rotation doesn't change. After applayng square B the rotation changes by +1 and -1 (mod 4). Then you move to the new position according to your new rotation.

alzika wrote:and keeping track

You can remember in an array which squares the path is already crossing.

alzika wrote:as well as finding the NUMBER of solutions instead of just finding if there is a path at all.

Don't just stop after you've found one path, but continue (by backtracking) to find all the paths.

Posted: **Mon Dec 12, 2005 2:06 am**

by **alzika**

Thanks.

Your assistance has led me to a greater outlook on this problem and I should be able to successfully complete it now.

Posted: **Fri Dec 16, 2005 9:00 am**

by **alzika**

The square A you have listed above, is there only 2 rotations for it, or 4? Meaning if it was the lower right corner square, should I count it twice for two different possible ways to arrive at the goal (if it has 4 rotations)?