## DMOPC '20 Contest 2 P1 - Laugh Graphs

View as PDF

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 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 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 _).

#### Input Specification

The first line will contain a single integer . The second line will contain a string of 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.

• commented on Dec. 18, 2020, 9:02 p.m.

why is there an error when I try to set a string to "\"?

• commented on Dec. 19, 2020, 1:01 a.m.
• commented on Dec. 7, 2020, 6:00 p.m.

For folks looking for reasons to do contests outside of DMOJ - this problem appeared on the most recent COCI contest.

• commented on Dec. 7, 2020, 5:57 p.m. edit 5

If anyone is getting stuck on this question, try inputting:

2
^^
Output should be:
./
/.