Codeforces Round #249 (Div. 2) C. 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 <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <utility>
#include <algorithm>
#include <cassert>
using namespace std;
//defines-general
typedef long long ll;
typedef long double ld;
#define to(a) __typeof(a)
#define fill(a,val) memset(a,val,sizeof(a))
#define repi(i,a,b) for(__typeof(b) i = a;i<b;i++)
//defines-pair
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
//defines-vector
typedef vector<int> vi;
typedef vector<long long> vll;
#define all(vec) vec.begin(),vec.end()
#define tr(vec,it) for(__typeof(vec.begin()) it = vec.begin();it!=vec.end();++it)
#define pb push_back
#define sz size()
#define contains(vec,x) (find(vec.begin(),vec.end(),x)!=vec.end())
int main()
{
vector<pii > vals;
char ans[][];
repi(i, , )
{
repi(j, , ) ans[i][j] = ' ';
}
int n;
cin >> n;
int x=,y=;
vals.pb(mp(x,y));
int maxy=;
int maxx=;
int add = ;
repi(i, , n)
{
int a;
cin >> a;
x+=a;
y+=((i%==)?:-)*a;
maxy = max(y,maxy);
maxx = max(x,maxx);
vals.pb(mp(x,y));
}
repi(i, , n+)
{
vals[i].ss = -*(vals[i].ss-maxy);
}
repi(i, , n+)
{
x = vals[i-].ff;
y = vals[i-].ss;
int x1 = vals[i].ff;
int y1 = vals[i].ss;
if(i%)
{
for(int j = y1+; j<=y; j++)
{
ans[j-][x1-(j-y1)] = '/';
}
}
else
{
for(int j = y+; j<=y1; j++)
{
ans[j-][x+(j-y-)] = '\\';
}
}
}
int maxi = ;
int maxj = ;
repi(i, , )
{
repi(j, , )
{
if(ans[i][j]!=' ')
{
maxi = max(i,maxi);
maxj = max(j,maxj);
}
}
}
repi(i, , maxi+)
{
repi(j, , maxj+) printf("%c",ans[i][j]);
cout << endl;
}
// for(pii temp:vals) cout << temp.ff <<" " << temp.ss << endl; cout << endl;
return ;
}
Codeforces Round #249 (Div. 2) C. Cardiogram的更多相关文章
- 模拟 Codeforces Round #249 (Div. 2) C. Cardiogram
题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单 ...
- Codeforces Round #249 (Div. 2) (模拟)
C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #249 (Div. 2) C题,模拟画图 ----未解决!
http://codeforces.com/contest/435/problem/C
- 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) 总结
D.E还是很难的.....C不想多说什么... A:提意:给出每一组人的个数,以及一次车载容量,求出最少需要多少次才能载走所有的人. water: http://codeforces.com/cont ...
- Codeforces Round #249 (Div. 2) A. Black Square
水题 #include <iostream> #include <vector> #include <algorithm> using namespace std; ...
- Codeforces Round #249 (Div. 2) B. Pasha Maximizes
看到题目的时候,以为类似插入排序,比较第i个元素和第i-1个元素, 如果第i个元素比第i-1个元素小,则不交换 如果第i个元素比第i-1个元素大,则交换第i个元素和第i-1个元素 继续比较第i-1个元 ...
随机推荐
- RPC笔记搬迁
选择dubbo 启动原理 解析服务 暴露服务 引用服务 提供服务流程 结合Netty 对比 HSF https://www.cnblogs.com/lichengwei/p/5529492.h ...
- 17-网页,网站,微信公众号基础入门(使用Adobe Dreamweaver CS6 制作网页/网站)
https://www.cnblogs.com/yangfengwu/p/11351182.html https://www.cnblogs.com/yangfengwu/p/11200767.htm ...
- 一篇JavaScript技术栈带你了解继承和原型链
作者 | Jeskson 来源 | 达达前端小酒馆 1 在学习JavaScript中,我们知道它是一种灵活的语言,具有面向对象,函数式风格的编程模式,面向对象具有两点要记住,三大特性,六大原则. 那么 ...
- libvirt原理
引用原文: https://blog.csdn.net/BtB5e6Nsu1g511Eg5XEg/article/details/80142155 libvirt是目前使用最为广泛的针对KVM虚拟机进 ...
- nginx之动静分离(nginx与php不在同一台服务器)
nginx实现动静分离(nginx与php不在同一个服务器) 使用wordpress-5.0.3-zh_CN.tar.gz做实验 Nginx服务器的配置: [root@app ~]# tar xf w ...
- selenuim自动化爬取汽车在线谷米爱车网车辆GPS数据爬虫
#为了实时获取车辆信息,以及为了后面进行行使轨迹绘图,写了一个基于selelnium的爬虫爬取了车辆gps数据. #在这里发现selenium可以很好的实现网页解析和处理js处理 #导包 import ...
- 代码注入/文件包含 弹出Meterpreter
主要通过 msf 中 exploit 的 web_delivery 模块来实现此功能 0x01 前提背景 目标设备存在远程文件包含漏洞或者命令注入漏洞,想在目标设备上加载webshell,但不想在目标 ...
- xargs 命令教程
转自阮一峰 http://www.ruanyifeng.com/blog/2019/08/xargs-tutorial.html 仅供个人交流学习 xargs是 Unix 系统的一个很有用的命令,但是 ...
- ubuntu之路——day19.1 深度CNN的探究
1.经典的CNN LeNet-5 1998的CNN鼻祖 以前用的sigmoid和tanh 下图给的是relu和softmax AlexNet ImageNet2012的冠军 VGG-16 ImageN ...
- 如何去掉word中英文单词下的红色波浪线
文件 ->选项 ->校对 在 只隐藏此文档中的拼写错误(S) 选项前打钩,点击确定即可