Under construction

Still being built. Things may change

Woodcut Traces

Interview

Time limit2sMemory limit128 MB

Summary
Simulate a tool moving on an N by N grid following U/D/L/R commands, ignoring out-of-bounds moves, and mark each point as unvisited, vertical-only, horizontal-only, or both.
Level

Easy3 of 10

Topics
Simulation, Matrix, Array
Solved
No attempts yet

Problem

The Department of Sculpture at W University built a woodcut machine to help students with repetitive woodblock work.

The machine moves a carving tool held by a robot arm in the four directions: up, down, left, and right. When a wooden board is placed under the tool, the machine automatically carves line traces on the board.

The board has N^2 points arranged at equal intervals in an N by N grid. The carving tool always starts on the top-left point.

Given the sequence of movement commands for the robot arm, print the traces left by the carving tool on the board.

If a command would move the robot arm outside the grid, the machine ignores that command and continues with the next one.

Input

The first line contains the board size N (2 <= N <= 10). This means the points form an N by N grid.

The second line contains the robot arm's movement commands as one string without spaces. U moves up, D moves down, L moves left, and R moves right. The command string has length at most 250.

Output

Print . for a point the robot arm never passed, | for a point it passed only vertically, - for a point it passed only horizontally, and + for a point it passed both vertically and horizontally.

The ASCII codes of these four characters are 46, 124, 45, and 43, respectively.

Examples3

  1. Example 1

    Input
    5
    DRDRRUU
    
    Expected output
    |..|.
    ++.|.
    .+-+.
    .....
    .....
    
  2. Example 2

    Input
    4
    RRRDDDDULL
    
    Expected output
    ---+
    ...|
    .--+
    ...|
    
  3. Example 3

    Input
    5
    RRDDLLUURRDDLLUUR
    
    Expected output
    +-+..
    |.|..
    +-+..
    .....
    .....