我是靠谱客的博主 安详酸奶,最近开发中收集的这篇文章主要介绍Codeforces Round #249 (Div. 2)C. Cardiogram,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
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.

Input

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.

Output

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.

Sample test(s)
Input
5
3 1 2 5 1
Output
 / 
 /  / 

 / 

 / 

 / 
Input
3
1 5 1
Output
 / 



 / 
Note

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


有些坑。。。

注意每行要填满,最大的x个字符

就是可能要用空格填坑


这次大概用了一个小时才有思路,

就是维护一个堆,画图

中途写好之后发现不能把/跟同样处理


之后又发现每行还要填坑。。。


#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<climits>
#include<list>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
struct st
{
int x,y;
int flag;
st(){}
st(int x,int y,int flag)
{
this->x=x;
this->y=y;
this->flag=flag;
}
bool operator <(st one)const
{
if(y!=one.y)
return y<one.y;
return x>one.x;
}
};
int main()
{
int n;
cin>>n;
int x=0,y=0;
priority_queue<st>qq;
set<st>vis;
vis.insert(st(x,y,1));
for(int i=0;i<n;i++)
{
int t;
cin>>t;
x+=t;
if(i%2==0)
{
y+=t;
if(i!=n-1)
qq.push(st(x,y,1));
else
qq.push(st(x,y,3));
}
else
{
y-=t;
vis.insert(st(x,y,1));
}
}
int px=0,py=qq.top().y;
while(qq.size())
{
st t=qq.top();
qq.pop();
if(vis.count(st(t.x,t.y,1)))
continue;
if(t.y!=py)
{
printf("%*sn",x-px,"");
px=0;
py=t.y;
}
if(t.flag==0)
{
printf("%*c",t.x-px,'/');
px=t.x;
qq.push(st(t.x-1,t.y-1,0));
}
else if(t.flag==2)
{
printf("%*c",t.x-px+1,92);
px=t.x+1;
qq.push(st(t.x+1,t.y-1,2));
}
else
{
printf("%*c",t.x-px,'/');
px=t.x;
qq.push(st(t.x-1,t.y-1,0));
if(t.flag!=3)
{
putchar(92);
px=t.x+1;
qq.push(st(t.x+1,t.y-1,2));
}
}
}
printf("%*sn",x-px,"");
}


最后

以上就是安详酸奶为你收集整理的Codeforces Round #249 (Div. 2)C. Cardiogram的全部内容,希望文章能够帮你解决Codeforces Round #249 (Div. 2)C. Cardiogram所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(59)

评论列表共有 0 条评论

立即
投稿
返回
顶部