2002 Canadian Computing Competition, Stage 2

Day 1, Problem 3: Return to Blind Man's Bluff

Note from admin: This problem makes more sense if you have already seen (and hopefully solved) Blindfold.

You have all played Blind Man's Bluff before, in an earlier Stage of life. In this sequel, you have even less information to work with, and you need to provide even more detailed responses. Recall that the "game" of Blind Man's Bluff is as follows: the player is placed in a known n×m playing area (with obstacles of size 1 square unit placed at various points in the playing area) pointing in one of the 4 compass directions (North, East, South, West). After repeatedly moving forward (F), turning right (R), or turning left (L), you were to determine your original starting position and the compass direction you were pointing in (either N=North, S=South, E=East, W=West).

We augment this game slightly now. Instead of simply determining your starting position and your direction, you are to determine the game board layout. That is, you are really playing this game blind. To help you in this endeavor, you are given the dimensions of the board, your starting position (in co-ordinates) and your starting orientation (either N=North, S=South, E=East, W=West).

You will accomplish this by a sequence of moves or move attempts. You have three such operations available to you: turn left 90 degrees, turn right 90 degrees, or attempt to move forward one square. The first two will always succeed, but the last may not; your program will be informed of whether it succeeds or fails.

You may assume that it is always possible to map out the whole game area from any given starting position. For example, consider the board:


Such a board would not appear in any of the test cases, because if you were placed at the centre square, it would be impossible to determine any squares of the board other than your starting position and its four neighbours.


Your program should read five lines from standard input, containing respectively:

  1. A single integer n (1 ≤ n ≤ 100), the number of rows in the field.
  2. A single integer m (1 ≤ m ≤ 100), the number of columns in the field.
  3. A single integer r (1 ≤ rn), your starting row on the board.
  4. A single integer c (1 ≤ cn), your starting column on the board.
  5. A single character, indicating your starting orientation: N, S, E, or W.

You may assume the common-sense convention of directions: north is decrease in row, south is increase in row, east is increase in column, and west is decrease in column.


Print n lines in north-south order, of m characters each in west-east order, indicating the layout of the grid. Use a period ('.') to represent a free square, and the capital letter X to represent a square containing an obstacle.


To turn left, print a line containing only the character 'L'. To turn right, print a line containing only the character 'R'. To attempt to move forward, print a line containing only the character 'F'. In the last case, the judge will then print the result: 1 if the move was successful, 0 if it was not, on a single line, which should be read by your program. (If your program attempts to print anything else before reading in the result of a query, it will probably result in a block and subsequent TLE.)

Sample Interaction

Here is an example of how your program might proceed. (Lines starting with "> " are read by your program, and lines starting with "< " are written by your program. These characters do not appear in the actual interaction.)
> 2
> 2
> 1
> 1
> 1
> N
< F
> 0
< R
< F
> 1
< F
> 0
< R
< F
> 1
< R
< F
> 0
< ..
< X.

All Submissions
Best Solutions

Point Value: 15
Time Limit: 2.00s
Memory Limit: 16M
Added: Feb 02, 2010

Languages Allowed:

Comments (Search)

Don't submit this problem. You will kill the judge. And I will be very very angry.

ready yet?

Unfortunately not. I haven't had time to work on interactive problem grading.

Are you going to fix this any time soon?