Codeforces Round #249 (Div. 2) (模拟)
1 second
256 megabytes
standard input
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.
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.
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.
5
3 1 2 5 1
/ \
/ \ / \
/ \
/ \
\ /
3
1 5 1
/ \
\
\
\
\ /
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) (模拟)的更多相关文章
- 模拟 Codeforces Round #249 (Div. 2) C. Cardiogram
题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单 ...
- Codeforces Round #249 (Div. 2) C题,模拟画图 ----未解决!
http://codeforces.com/contest/435/problem/C
- Codeforces Round #249 (Div. 2) 总结
D.E还是很难的.....C不想多说什么... A:提意:给出每一组人的个数,以及一次车载容量,求出最少需要多少次才能载走所有的人. water: http://codeforces.com/cont ...
- Codeforces Round #249 (Div. 2)B(贪心法)
B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- 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 ...
- Codeforces Round #249 (Div. 2) D. Special Grid 枚举
题目链接: http://codeforces.com/contest/435/problem/D D. Special Grid time limit per test:4 secondsmemor ...
- Codeforces Round #249 (Div. 2) A B
C好像就是个模拟.D 是个编码复杂度大的,可是好像也就是枚举三角形,我这会儿准备区域赛,尽量找点思维难度大的,所以昨晚A B 还是去做区域赛题吧..... B 也有点意思 贪心 题意:交换相邻两个位的 ...
- Codeforces Round #382 (Div. 2) (模拟|数学)
题目链接: A:Ostap and Grasshopper B:Urbanization C:Tennis Championship D:Taxes 分析:这场第一二题模拟,三四题数学题 A. 直接模 ...
- Codeforces Round #249 (Div. 2) C. Cardiogram
C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...
随机推荐
- jQuery 文档操作
一.插入操作 1. 父元素.append(子元素) 追加某元素,在父元素中添加新的子元素, 子元素可以为: stirng / element (js对象) / jquery 元素 var oli = ...
- IOS系统兼容input keyup事件
最近在做移动端模糊搜索功能,js监听input的keyup事件,在chrom模拟器和android手机环境运行都没有问题,到了ios手机却出现bug,没法实现功能: 查了好一会资料,发现keyup事件 ...
- C#-委托 lambda 匿名方法 匿名类型
1.lambda 匿名方法 匿名类型 delegate void d1(); d1 d = delegate(){Console.WriteLine("this is a test" ...
- WinServer-授权规则
授权规则: 使用谓词可以限制网站只能使用某一种请求 来自为知笔记(Wiz)
- Servlet里面一调用Dao里的某个方法
背景: 这几天,由于项目集成的需要,我要在doFilter里调用dao层里的某些方法,可是总之报空指针,只要调用那个dao方法,就报错误.很是纳闷,网上查找了各种原因,终于让我给突破了,看来还是Jav ...
- hdu 5077 NAND(打表)2014 Asia regional 鞍山站 H题
题目链接:点击打开链接 题意:就是一个按位运算的一个函数.问最少经过多少步运算能够得到给定数. 思路:不是我投机取巧想打表.是特么这题仅仅能打表.. .打表思想用能够得到的数的集合表示状态bfs:最后 ...
- DB-MySQL:MySQL 运算符
ylbtech-DB-MySQL:MySQL 运算符 MySQL 运算符 本章节我们主要介绍 MySQL 的运算符及运算符的优先级. MySQL 主要有以下几种运算符: 算术运算符 比较运算符 逻辑运 ...
- asp.net 汉字转拼音的车祸现场
asp.net 汉字转拼音 需求背景: 昨天遇到个问题,就是面对系统中集中性的要设置大批量的用户设置默认的用户名,密码,权限(角色),同时要求用户名是姓名的全拼,回头看看旁边那个哥们撸胳膊挽袖子准备一 ...
- 解决win8.1下sql配置iis的问题
在配置iis8.5时,ISAPI和CGI限制中没有ASP.NET v4.0.30319, 所以要注册.net 4.0 注册方法为在“运行”中输入cmd,然后在命令行中输入: C:\WINDOWS\Mi ...
- ubuntu上配tensorflow
前一阵绕了大弯路,基本弄好了UEFI双系统后,面对的就是CUDA咋装在Linux. 好在教程好多,有些朋友建议先装CUDA再装显卡驱动.弄好之后记录一下详细过程吧. *** 这两天看了一些教程,还是感 ...