国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > php开源 > 综合技术 > Codeforces Round #249 (Div. 2)C. Cardiogram

Codeforces Round #249 (Div. 2)C. Cardiogram

来源:程序员人生   发布时间:2015-05-22 08:16:29 阅读次数:2951次
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个字符

就是可能要用空格填坑


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

就是保护1个堆,画图

中途写好以后发现不能把/跟一样处理


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


#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⑴) 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("%*s ",x-px,""); px=0; py=t.y; } if(t.flag==0) { printf("%*c",t.x-px,'/'); px=t.x; qq.push(st(t.x⑴,t.y⑴,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⑴,2)); } else { printf("%*c",t.x-px,'/'); px=t.x; qq.push(st(t.x⑴,t.y⑴,0)); if(t.flag!=3) { putchar(92); px=t.x+1; qq.push(st(t.x+1,t.y⑴,2)); } } } printf("%*s ",x-px,""); }


生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生