COCI '20 Contest 2 #1 Crtanje

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem type

Josip used to code in Logo. He loved to draw pictures, but those days are sadly over. Nostalgic, he decided to draw a line that represents the net worth of his company over a period of n days.

For each of the n days, he knows if the net worth of his company increased by one unit (represented by +), decreased by one unit (represented by -), or remained the same (represented by =) during that day. Before the first day, the net worth was equal to zero.

Josip will draw the line in a big infinite matrix of characters. Indices of matrix rows grow upwards, and indices of columns grow to the right. For the i-th day he will draw some character in the i-th column.

The character and the index of the row are decided by the following rules:

  • If the net worth increased during the i-th day, he will draw / in the row with index equal to the net worth at the beginning of the day.
  • If the net worth decreased during the i-th day, he will draw \ in the row with index equal to the net worth at the end of the day.
  • If the net worth didn't change during the i-th day, he will draw _ in the row with index equal to the net worth during the day.

All other cells are filled with ..

Your task is to output the minimal matrix that contains the whole line, i.e. contains all characters /, \ and _ that Josip drew.

Input

The first line contains an integer n (1 \le n \le 100), the number of days.

The second line contains a string of n characters +, - and = that represents how the company's net worth changed over the given period.

Output

Output the described matrix.

Scoring

In test cases worth 40\% points the input won't contain the character -.

Sample Input 1

7
++---==

Sample Output 1

./\....
/..\...
....\__

Sample Input 2

5
+=+=+

Sample Output 2

..._/
._/..
/....

Sample Input 3

4
--=+

Sample Output 3

\...
.\_/

Comments


  • 0
    cyberboost  commented on Feb. 13, 2024, 12:33 a.m.

    Can somebody explain to me how to get the starting row?


  • 0
    caravansary  commented on March 26, 2023, 6:25 p.m.

    Could someone explain the sample output 1 for me? I could not get that output following the rules outlined in the problem.


    • 2
      dnialh_  commented on March 26, 2023, 9:21 p.m.

      It might be easier to explain if you show the output that you get from your interpretation of the rules.

      The best explanation I can currently give is just that it looks like the graph of a function going up twice, down three times, and staying flat twice.


      • 0
        caravansary  commented on March 27, 2023, 12:07 a.m. edited

        Thank you for your response. From my interpretation: '/' at (0,1) position (net worth = 0 at the beginning of day 1). '/' at (1,2) (net worth = 1 at the beginning of day 2). '\' at (1,3) (net worth = 1 at the end of day 3). '\' at (0,4). '\' at (-1,5)=(3,5). '_' at (3,6). '_' at (3,7). Where did I go wrong? Thanks again.


        • 1
          dnialh_  commented on March 27, 2023, 4:58 a.m. edited

          It seems like you think that when the row-value goes negative the position of the drawing should loop around (like in python indexing). However, we instead want to continue going 'below the axis' (as we would when drawing a graph on the coordinate axes).

          In particular, in Sample 1 the rows in the Sample Output are:

          Row 1
          Row 0
          Row -1

          (The indices increase as we go upwards, as stated in the problem statement).


  • -2
    pyhead42  commented on Oct. 13, 2022, 5:53 a.m.

    Make sure you come up with your own varied test cases. My lack of imagination in this regard hung me up for quite awhile. It should look like a proper dashed line on a dotted background.


  • -1
    stuart314159  commented on June 29, 2022, 1:59 p.m.

    A hard edge case is to guarantee the "minimal" matrix, which can be done either with complex logic or simply dropping lines that only consist of points...


  • 1
    Blackgaurdian3  commented on Jan. 1, 2021, 3:07 a.m.

    Why is this worth as much as https://dmoj.ca/problem/dmopc20c2p1


    • 10
      sortSlave  commented on Jan. 1, 2021, 4:00 a.m.

      it's the exact same problem lmao