模拟 Codeforces Round #249 (Div. 2) C. Cardiogram

时间:2022-08-11 08:35:48

题目地址:http://codeforces.com/contest/435/problem/C

 /*
题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:)
模拟题:蛮恶心的,不过也简单,依据公式得知折线一定是一上一下的,只要把两个相邻的坐标之间的折线填充就好
注意:坐标有可能为负数,所以移动值y初始化为1000,最后要倒过来输出
详细解释:http://blog.csdn.net/zhb1997/article/details/27877783
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <set>
using namespace std; const int MAXN = 1e3 + ;
const int INF = 0x3f3f3f3f;
int map[MAXN<<][MAXN<<];
int a[MAXN]; int main(void) //Codeforces Round #249 (Div. 2) C. Cardiogram
{
//freopen ("G.in", "r", stdin); int n;
while (~scanf ("%d", &n))
{
int tot = ; int mx = , mn = , x = , y = ;
for (int i=; i<=n; ++i) scanf ("%d", &a[i]), tot += a[i]; memset (map, , sizeof (map));
for (int i=; i<=n; ++i)
{
x++;
if (i & ) //奇数一定'/'
{
a[i]--;
map[y][x] = ;
while (a[i]--)
{
x++; y++;
map[y][x] = ;
}
mx = max (mx, y);
}
else //偶数一定'\'
{
a[i]--;
map[y][x] = ;
while (a[i]--)
{
x++; y--;
map[y][x] = ;
}
mn = min (mn, y);
}
} //printf ("%d %d\n", mx, mn);
for (int i=mx; i>=mn; --i) //y坐标
{
for (int j=; j<=tot; ++j) //x坐标
{
if (map[i][j] == ) printf ("/");
else if (map[i][j] == ) printf ("\\");
else printf (" ");
}
puts ("");
}
} return ;
}