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 ...
随机推荐
- a.WHERE使用中单行子查询(适用于>,<,=,>=,<=等条件)
a.单行子查询(适用于>,<,=,>=,<=等条件) //查询工资最高的员工编号和员工名 select empno,ename from emp where ...
- luogu 1865 数论 线性素数筛法
洛谷 1865 数论 线性素数筛法 最基本的线性素数筛法,当做复习欧拉筛法了,没有尝试过使用更暴力的筛法... WA了一次,手抖没打\n 传送门 (https://www.luogu.org/prob ...
- java开发必背API
1.java.io.file类,File用于管理文件或目录: 所属套件:java.io File file = new File(fileStringPath); 1)file.mk(),真的会创建一 ...
- 12:打印 1 到最大的 n 位数
题目:输入数字 n.按顺序打印出从 1 到 最大的 n 位十进制数.比方输入 3 ,则打印出 1.2 .3 一直到最大的3位数即 999. 解析: easy知道不能用 int 等数字类型表示(大数问题 ...
- 上机题目(0基础)-计算两个正整数的最大公约数和最小公倍数(Java)
题目例如以下:
- server.htaccess 具体解释以及 .htaccess 參数说明
.htaccess文件(或者"分布式配置文件")提供了针对文件夹改变配置的方法. 即.在一个特定的文档文件夹中放置一个包括一个或多个指令的文件, 以作用于此文件夹及其所有子文件夹. ...
- iOS Autolayout情况下,ViewController嵌套时,childViewController的Frame异常问题
近期项目中,使用Storyboard.AutoLayout开发,某个ViewController中嵌套了多个子ViewController,结果在将其加入到父ViewController时,出现坐标异 ...
- 英语影视台词---七、THE GREAT GATSBY QUOTES
英语影视台词---七.THE GREAT GATSBY QUOTES 一.总结 一句话总结:了不起的盖茨比 1.“So we beat on, boats against the current, b ...
- linux系统定时任务crond入门
1,Crond: Crond是linux系统中用来定期执行命令或指定程序任务的一种服务或者软件.(Centos5以后默认存在) 当优化开机自启动的时候,第一个就是crond. Crond服务默认情况( ...
- POJ 1990 线段树
题意: 思路: 线段树 (一棵就够啦 不像树状数组,还得用两棵) 先对v从小到大排序.每回插入的时候当前的v是最大的,只需要统计它到各个坐标的距离就好了. 里面存两个东西: 这个坐标左边的坐标个数和这 ...