DRAWM - Draw Mountains
You are a member of a team that is working in a new wonderful graphics program. Your task is to write a module for drawing skylines of mountains. However, for now the program is in beta version, so each skyline is discretized. This means that your module receives as input a sequence of integers representing heights. Each pair of consecutive heights in the sequence may differ by at most 1 and produces a column of output, each column containing a single character. The particular character to write and its position in the column depend on the pair of heights. When both heights are equal an underscore (“ ”) must be printed. If the heigths within the pair increase or decrease, you must write a slash (“/”) or a backslash (“\”), respectively. The position of the character in the column is such that the skyline visually respect the given heights. For instance, the sequence of heights (1, 2, 3, 2, 3, 3, 2, 1, 0) must produce the skyline shown in the following figure.
_ /\/ \ / \ \
Notice that when the sequence of heights has C + 1 elements, the corresponding skyline has only C columns. Given a sequence of heights, you must draw the skyline according to the rules given above. See the examples for further clarification.
Input
The input contains several test cases, each one described in exactly two lines. The first line contains an integer C indicating the number of columns of the skyline (1 ≤ C ≤ 70). The second line contains C + 1 integers Hi separated by single spaces representing the sequence of heights (0 ≤ Hi ≤ 30 for 1 ≤ i ≤ C + 1). You may assume that there exist an height Hi = 0, and that the difference between succesive heights is at most 1 (i.e. |Hi − Hi+1 | ≤ 1 for 1 ≤ i ≤ C). The last line of the input contains a single −1 and should not be processed as a test case.
Output
For each test case output the correponding skyline, followed by a line with exactly three asterisks (“***”). While writting the skyline, use only regular spaces, newlines, and the three characters mentioned in the statement. Ths skyline must be left aligned and it must contain exactly C columns. There must be no trailing spaces at the end of printed lines, neither empty lines.
Example
Input: 8 1 2 3 2 3 3 2 1 0 3 1 0 0 1 -1 Output: _ /\/ \ / \ \ *** \_/ ***
hide comments
psz2007:
2021-10-12 14:53:40
Ac in one go! :) gl to everyone who what to solve the problem.
|
|
raschu:
2017-06-10 11:49:04
AC in one go!
|
|
Daniel:
2016-12-23 07:23:35
@Santiago Zubieta
|
|
:.Mohib.::
2015-06-29 11:43:11
Nice One.... :) |
|
Nebojsa:
2015-03-25 12:20:00
Great problem! My 100th on SPOJ :)) |
|
joud zouzou:
2013-05-18 12:22:29
I tried the test cases and even tried to print x instead of space like santiago zubieta said, eventhough i got WA, what would the problem be? |
|
jaans:
2012-06-27 07:34:32
:D understud the ques completly wrng :P but when got the ques right :D guess what AC in first attempt :D and random_gal :* u r a genius |
|
Loving Primes Yummy :D :):
2012-06-20 06:42:52
@Santiago Zubieta
|
|
Santiago Palacio:
2012-01-12 20:09:27
What i love the most of this problem, is that the result is fun. |
|
Santiago Zubieta:
2011-06-13 08:51:40
I don't have any trailing spaces
|
Added by: | Pablo Ariel Heiber |
Date: | 2010-08-22 |
Time limit: | 1.919s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS OBJC PERL6 VB.NET |
Resource: | FCEyN UBA ICPC Selection 2009 |