DMOPC '20 Contest 2 P1 - Laugh Graphs

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Everyone knows that laughter comes in three types of pitches: up, down, and right. Kiara is especially interested in the laughing patterns of her friend, and wishes to graph it out to see what interesting shapes come out.

Kiara wants you to generate the graph of a laugh that is N pitches long. Each pitch will be given to you either as the character ^ (for up), v (for down), or > (for right).

To generate the graph, imagine that you are working on a 2D grid of characters with infinite rows and N columns. In the beginning, all characters in the grid are set to ., and your cursor is positioned in the first column. For every pitch given to you, perform the respective action:

  • ^ pitch: replace the current character with /, and move the cursor one character to the right and one character up.
  • v pitch: move the cursor one character down, replace the current character with \, and move the cursor one character to the right.
  • > pitch: replace the current character with _, and move the cursor one character to the right.

Although our hypothetical grid has infinite rows, for ease of comprehension, you should output only the rows which contain a character that is not . (i.e. print out all rows that contain one of /, \, or _).

Constraints

1 \le N \le 1\,000

Input Specification

The first line will contain a single integer N. The second line will contain a string of N characters, each of which will be one of ^, v, or >.

Output Specification

Output the laugh graph, using the procedure described.

Sample Input 1

6
vv>^^^

Sample Output 1

...../
\.../.
.\_/..

Sample Input 2

5
vvvvv

Sample Output 2

\....
.\...
..\..
...\.
....\

Explanation of Sample Output 2

Note that only rows containing non-. characters should be included.


Comments