cf435C Cardiogram
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
又一模拟题。。。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#define ll long long
#define inf 0x7fffffff
using namespace std;
inline int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x*=10;x+=ch-'0';ch=getchar();}
return x*f;
}
int n,tot,mx=1000,mn=1000,x,y=1000;
int a[1005];
int b[2005][2005];
int main()
{
n=read();
for(int i=1;i<=n;i++)
a[i]=read(),tot+=a[i];
for(int i=1;i<=n;i++)
{
x++;
if(i&1)
{
a[i]--;
b[x][y]=1;
while(a[i]--)
{
x++;y++;
b[x][y]=1;
}
mx=max(mx,y);
}
else
{
a[i]--;
b[x][y]=2;
while(a[i]--)
{
x++;y--;
b[x][y]=2;
}
mn=min(mn,y);
}
}
for(int i=mx;i>=mn;i--)
{
for(int j=1;j<=tot;j++)
if(b[j][i]==1)printf("/");
else if(b[j][i]==2)printf("\\");
else printf(" ");
printf("\n");
}
return 0;
}
cf435C Cardiogram的更多相关文章
- 模拟 Codeforces Round #249 (Div. 2) C. Cardiogram
题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单 ...
- Codeforces Round #249 (Div. 2) C. Cardiogram
C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 【奶昔队ROUND#1】
奶昔队Round #1 热身 (奶昔队不是真正的队,是群) CodeForces 435C Cardiogram 模拟,不过我做的时候不是模拟,是计算...(写了好久,还wa了几次),现在看了别人的代 ...
- 2015.05.15,外语,学习笔记-《Word Power Made Easy》 02 “如何谈论医生”
包括Sessions 4-6: Prefix Person,nous,etc. Practice,etc. Adjective internus内部 internist [ɪn'tɝnɪst] n.内 ...
- Codeforces Round #249 (Div. 2) (模拟)
C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...
随机推荐
- ActionScript通用开发框架
ActionScript 3(简称as)自2006年诞生以来,出现了一大批很优秀框架.就我的知识领域,运用包括pureMVC.pushButton Engine(组件框架).Robotlegs.Ash ...
- android ViewPager具体解释
Viewpager 在android界面布局中属于经常使用类型 ,它能够做导航,页面菜单,进入软件是的欢迎界面 等等.比方今最流行的几款手机软件 ,QQ,微信,微博 等 ,其主界面 都用到了View ...
- Cocos2d-x 3.x 头像选择,本地相册图片+图片编辑(Android、IOS双平台)
大连游戏产业不是很发达,最后,选择一个应用程序外包公司.积累的工作和学习过程中的一点业余生活微信体验,我想分享的游戏小朋友的爱. 在应用开发过程中会经常实用户上传头像的功能,在网上找了N多资料发现没有 ...
- 【c#】Form调用百度地图api攻略及常见问题
首先,在Form中调用百度地图api,我们需要使用webbrowser控件,这个在前面的文章中已经讲过了,可以参照(http://blog.csdn.net/buptgshengod/article/ ...
- Java 异常处理的误区和经验总结--转载
本文着重介绍了 Java 异常选择和使用中的一些误区,希望各位读者能够熟练掌握异常处理的一些注意点和原则,注意总结和归纳.只有处理好了异常,才能提升开发人员的基本素养,提高系统的健壮性,提升用户体验, ...
- 从零开始写一个Tomcat(贰)--建立动态服务器
上文书说道如何通过http协议建立一个静态的服务器来访问静态网页,但我们选择tomcat最主要的原因还是因为它能动态的执行servlet,这边文章将引导你实现一个能够运行servlet的服务器,这个简 ...
- CXF WebService整合Spring
转自http://www.cnblogs.com/hoojo/archive/2011/03/30/1999563.html 首先,CXF和spring整合需要准备如下jar包文件: 这边我是用Spr ...
- 关于js跨域
get方式: 称为jsonp,就是js的跨域通信方式,因为知道有些标签可以跨域获取内容,例如img,script,link...,jsonp就是把动态创建一个script标签,然后配置src属性,后台 ...
- VS2013配置文件常见问题解决方法
1.C++ VS2013出现LINK : fatal error LNK1104: 无法打开文件“kernel32.lib,”错误,什么原因啊?原因:项目->XX(项目名称)属性->链接器 ...
- 推荐一个CMMI认证查询网站
随着软件企业的增多和意识的增强,越来越多公司开始做CMMI的认证评估,由于国内网速和CMMI官网的网站综合原因,打开速度超级慢. 所以本文推荐一个CMMI认证查询网站,认证后的结果查询可以点这里查询: ...