C. Cardiogram
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Your task is to paint a cardiogram by given sequence ai.

Input

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.

Output

Print max |yi - yj| lines (where
yk is the
y coordinate of the
k-th point of the polyline), in each line print 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.

Sample test(s)
Input
5
3 1 2 5 1
Output
      / \
 / \ /  \
 /  \
 /  \
\ / 
Input
3
1 5 1
Output
 / \
\
\
\
\ / 
Note

Due to the technical reasons the answers for the samples cannot be copied from the statement. We've attached two text documents with the answers below.

http://assets.codeforces.com/rounds/435/1.txt

http://assets.codeforces.com/rounds/435/2.txt

题目链接:http://codeforces.com/problemset/problem/435/C

题目大意:打印如图所看到的的图案,開始图形斜上。

解题思路:数组存储模拟。数组大小2000*2000。横坐标从1000处開始模拟。

初始化全部字符为空格,标记每条坡的最高值和最低值。这里最高和最低反过来思考,由于打印时是从上往下的,即上面是坡的低值。以下是坡的高值。第奇数个坡是上升的,次对角线时字符为‘/’,第偶数个坡值是下降的,主对角线上字符为'\',(注意,打印时这样输出‘\\’),找到整个图形横坐标的最大值和最小值,即横坐标的范围,就能输出整个图形了。

代码例如以下:

#include <cstdio>
#include <cstring>
int const maxn=2005;
char eg[maxn][maxn];
int a[maxn],hg[maxn],lw[maxn];
int main()
{
int n;
scanf("%d",&n);
int ma=1000,mi=1000; //整个图形的最高点和最低点
hg[0]=1000;
for(int i=0;i<maxn;i++)
for(int j=0;j<maxn;j++)
eg[i][j]=' ';
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
if(i%2==0) //记录每条坡值的最高点和最低点
{
lw[i]=lw[i-1];
hg[i]=lw[i]+a[i];
if(ma<hg[i])
ma=hg[i];
}
else
{
hg[i]=hg[i-1];
lw[i]=hg[i]-a[i];
if(mi>lw[i])
mi=lw[i];
}
}
int x=0; //标记每条坡開始的纵坐标
for(int i=1;i<=n;i++)
{
if(i%2==0)
{
for(int k=lw[i];k<hg[i];k++)
for(int j=x;j<x+a[i];j++)
if(j-x==k-lw[i]) //主对角线上
eg[k][j]='\\';
}
else
{
for(int k=lw[i];k<hg[i];k++)
for(int j=x;j<x+a[i];j++)
if(j-x==a[i]-k+lw[i]-1) //次对角线上
eg[k][j]='/';
}
x+=a[i];
}
for(int i=mi;i<ma;i++) //横坐标从mi到ma
{
for(int j=0;j<x;j++)
printf("%c",eg[i][j]);
printf("\n");
}
}

Codeforces Round #249 (Div. 2) (模拟)的更多相关文章

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

    题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单 ...

  2. Codeforces Round #249 (Div. 2) C题,模拟画图 ----未解决!

    http://codeforces.com/contest/435/problem/C

  3. Codeforces Round #249 (Div. 2) 总结

    D.E还是很难的.....C不想多说什么... A:提意:给出每一组人的个数,以及一次车载容量,求出最少需要多少次才能载走所有的人. water: http://codeforces.com/cont ...

  4. Codeforces Round #249 (Div. 2)B(贪心法)

    B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  5. Codeforces Round #249 (Div. 2) A题

    链接:http://codeforces.com/contest/435/problem/A   A. Queue on Bus Stop time limit per test 1 second m ...

  6. Codeforces Round #249 (Div. 2) D. Special Grid 枚举

    题目链接: http://codeforces.com/contest/435/problem/D D. Special Grid time limit per test:4 secondsmemor ...

  7. Codeforces Round #249 (Div. 2) A B

    C好像就是个模拟.D 是个编码复杂度大的,可是好像也就是枚举三角形,我这会儿准备区域赛,尽量找点思维难度大的,所以昨晚A B 还是去做区域赛题吧..... B 也有点意思 贪心 题意:交换相邻两个位的 ...

  8. Codeforces Round #382 (Div. 2) (模拟|数学)

    题目链接: A:Ostap and Grasshopper B:Urbanization C:Tennis Championship D:Taxes 分析:这场第一二题模拟,三四题数学题 A. 直接模 ...

  9. Codeforces Round #249 (Div. 2) C. Cardiogram

    C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...

随机推荐

  1. java方法名的重载

    方法的重载:方法名相同,参数不同,按照参数类型进行匹配 创建一个Simple 类,然后定义了两个方法 package cuteSnow; public class Simple { // 方法的重载, ...

  2. oracle 控制语句

    PL输出语句 set serverout on; -- 开启PL的输出语句功能declare n number:=1; -- 声明一个number型的变量n,并赋值为1 v varchar2(20): ...

  3. Xshell 安装 Xftp

    一.下载 Xftp 链接:https://pan.baidu.com/s/1dGeL2gD 密码:as9x 二.安装 Xftp 无脑下一步 三.点击 Xshell 上的新建文件传输 四.弹出 xftp ...

  4. 监控SQLserver计数器

  5. 洛谷 P2949 [USACO09OPEN]工作调度Work Scheduling

    P2949 [USACO09OPEN]工作调度Work Scheduling 题目描述 Farmer John has so very many jobs to do! In order to run ...

  6. poj2528 Mayor&#39;s posters(线段树,离散化)

    离散化的思想: 对于这样的数据 (3,10000). (9,1000000). (5.100000), (1,1000). (7,1000000) 我们能够将其处理为 (2,7). (5,9). (3 ...

  7. 走进windows编程的世界-----入门篇

    1   Windows编程基础 1.1Win32应用程序基本类型 1)  控制台程序 不须要完好的windows窗体,能够使用DOS窗体方式显示 2)  Win32窗体程序 包括窗体的程序,能够通过窗 ...

  8. cocos2d-x_AnchorPoint锚点

    锚点是定位和变换操作的一个重点.锚点我们能够看成用一根图钉将一张纸或者相片钉在墙上的那个点. 节点的位置是由我们设置的position和anchor point一起决定的. 值得一提的是,anchor ...

  9. leetcode 题解 || Longest Common Prefix 问题

    problem: Write a function to find the longest common prefix string amongst an array of strings. 寻找 0 ...

  10. 21.boost Ford最短路径算法(效率低)

    到某个节点最近距离                  最短路径当前节点的父节点 完整代码 #include <iostream> #include <string> #incl ...