# 【cf435C】Cardiogram

## 描述 Description

In this problem, your task is to use ASCII graphics to paint a cardiogram.

A cardiogram is a polyline with the following corners:

That is, a cardiogram is fully defined by a sequence of positive integers a1, a2, …, an.

## 输入格式 InputFormat

The first line contains integer n (2 ≤ n ≤ 1000). The next line contains the sequence of integers a1, a2, …, an (1 ≤ ai ≤ 1000). It is guaranteed that the sum of all ai doesn’t exceed 1000.

## 输出格式 OutputFormat

Print max |yi - yj| lines (where yk is the y coordinate of the k-th point of the polyline), in each line print [latex]sum_{i=1}^{n}a_{i}[/latex] characters. Each character must equal either « / » (slash), « » (backslash), « » (space). The printed image must be the image of the given polyline. Please study the test samples for better understanding of how to print a cardiogram.
Note that in this problem the checker checks your answer taking spaces into consideration. Do not print any extra characters. Remember that the wrong answer to the first pretest doesn’t give you a penalty.

3
2 1 2

## 样例输出 SampleOutput

`

/
//
/
`

Codeforces 435C

## 代码 Code

#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
#define inf 0x7fffffff/27.11
struct point
{
int z,y,x;
}p[1001];
int a[1001];
char g[1001][1001];
int i,j,t,n,m,l,r,k,xmax,xmin,ymax,ymin,tx,ty;
char ch;
int main()
{
scanf("%d",&n);
for (i=1;i<=n;i++) scanf("%d",&a[i]);
ymin=inf;ymax=-inf;
for (i=1;i<=n;i++)
{
p[i].x=p[i-1].x+a[i];
p[i].y=p[i-1].y;
if (i%2==0) p[i].y-=a[i];
else p[i].y+=a[i];
ymax=max(ymax,p[i].y);
ymin=min(ymin,p[i].y);
}
for (i=1;i<=n;i++)
{
if (p[i].y>p[i-1].y)
{
ch='/';
for (j=p[i-1].x+1;j<=p[i].x;j++)
{
tx=ymax-(p[i-1].y+(j-p[i-1].x))+1;ty=j;
g[tx][ty]=ch;
}
}
else
{
ch=(char)92;
for (j=p[i-1].x+1;j<=p[i].x;j++)
{
tx=ymax-(p[i-1].y-(j-p[i-1].x));ty=j;
g[tx][ty]=ch;
}
}
}
for (i=1;i<=max(ymax,0)-min(ymin,0);i++)
{
if (i>1) printf("n");
for (j=1;j<=p[n].x;j++)
{
if (g[i][j]=='/' || g[i][j]==(char)92) printf("%c",g[i][j]);
else printf(" ");
}
}
return 0;
}