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 ...
随机推荐
- JAVA ,SSH中文及其乱码问题的解决 6大配置点 使用UTF-8编码
JSP,mysql,tomcat下(基于struts2)中文及其乱码问题的解决 6大配置点 使用UTF-8编码 目前对遇到J2EE 开发中 中文及其乱码问题,参考网上资料做个总结, 主要是6大配置点: ...
- [Javascript] Array methods in depth - slice
Array slice creates a shallow copy of an array. In this lesson we cover, in detail, exactly what a ' ...
- yii中常用路径<转>
调用YII框架中jquery:Yii::app()->clientScript->registerCoreScript(‘jquery’); framework/web/js/source ...
- 话付通SDK 聚合支付
步骤 官网:http://www.71pay.cn/ 1.导入Jar包----将HeepayPlugin.jar,HftJuhePay.jar 包放入工程指定的libs目录. 2.配置清单文件---- ...
- C#Linq的使用
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- Thinkphp 上传图片
<?php // 本类由系统自动生成,仅供测试用途 class ListAction extends Action { public function index(){ //$name = 's ...
- Android时间戳转换为标准Datetime(yyyy-MM-dd hh:mm:ss)格式
下列函数为实现过程,已经测试通过. /// <summary> /// Android时间戳转换为标准Datetime /// </summary> /// <param ...
- Hyper-V虚拟机和主机的网络配置
Hyper-V虚拟机和主机的网络配置 方式1.共享式 这种方式是将Hyper-V内部的虚拟网络与外部网络共享.使得内部是一个私有的网络.属于NAT的类型.(不知道这么说对不对) 优点: 相对来说属于私 ...
- SQL SERVER 查询特定的前几条数据
1. 使用MS SQL Server 2008: 2. 数据库内容如下: insert into xuexi1 values('张三0', '数学', 98 ) insert into xuexi1 ...
- react-native-router-flux 下部导航
github url:https://github.com/aksonov/react-native-router-flux API: https://github.com/aksonov/react ...