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个元 ...
随机推荐
- presto-gateway 试用以及docker 镜像制作
presto-gateway 是 lyft 团队开源 的prestodb 的工具.以下是一个简单的试用,以及碰到问题的解决 还有就是docker 镜像的制作 Dockerfile 很简单,本地构建然后 ...
- [RN] React Native ScrollView自动滑动到顶部
react-native 自动滚到屏幕顶部,模仿微信朋友圈评论自动定位 <ScrollView showsVerticalScrollIndicator={false} style={[styl ...
- linux 配置启动supervisor详细
参考自强学堂:https://code.ziqiangxuetang.com/django/django-nginx-deploy.html 例子中zqxt项目 安装 supervisor 软件包 ( ...
- LSF 作业系统常用命令
LSF(Load Sharing Facility)是一个被广泛使用的作业管理系统,具有高吞吐.配置灵活的优点.通过 LSF 集中监控和调度,可以充分利用计算机的CPU.内存.磁盘等资源. bqueu ...
- proxmox之cloud-init
Cloud-Init支持 Cloud-Init是事实上的多分发包,它处理虚拟机实例的早期初始化.使用Cloud-Init,可以在虚拟机管理程序端配置网络设备和ssh密钥.当VM首次启动时,VM内的Cl ...
- html内获取当前文件路径,页面获取当前路径
function getRealPath(){ var curWwwPath = window.document.location.href; var pathName = window.docume ...
- java并发编程(八) CAS & Unsafe & atomic
参考文档:https://www.cnblogs.com/xrq730/p/4976007.html CAS(Compare and Swap) 一个CAS方法包含三个参数CAS(V,E,N).V表示 ...
- 强烈建议为你的Android项目加上 largeHeap 属性
小内存机器使用“微信”时,看视频经常崩溃(out of memory) ,小内存机器有时候明明内存还很多,却还是抛出“内存不够”,应该就是每个APP能用“堆大小”的限制. 如上图,Android项目的 ...
- jQuery的zTree插件
写在前面 jQuery的 zTree插件 关键代码 <%@ page language="java" contentType="text/html; charset ...
- mysql插入数据报错IntegrityError: (1062, "Duplicate entry 'xx' for key 'xxxxx'")
1.问题描述 MySQL插入数据的时候报错,提示如下: IntegrityError: (1062, "Duplicate entry 'xx' for key 'xxxxx'") ...