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

概述

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

//includes
#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 [ 2000 ][ 2000 ];
      repi( i , 0 , 2000)
      {
            repi( j , 0 , 2000) ans [ i ][ j ] = ' ';
      }
      int n;
      cin >> n;
      int x = 0 , y = 0;
      vals .pb( mp( x , y));
      int maxy = 0;
      int maxx = 1;
      int add = 1;
      repi( i , 0 , n)
      {
            int a;
            cin >> a;
            x += a;
            y +=(( i % 2 == 0) ? 1 :- 1) * a;
            maxy = max( y , maxy);
            maxx = max( x , maxx);
            vals .pb( mp( x , y));
      }
      repi( i , 0 , n + 1)
      {
            vals [ i ].ss = - 1 *( vals [ i ].ss - maxy);
      }
      repi( i , 1 , n + 1)
      {
            x = vals [ i - 1 ]. ff;
            y = vals [ i - 1 ].ss;
            int x1 = vals [ i ]. ff;
            int y1 = vals [ i ].ss;
            if( i % 2)
            {
                  for( int j = y1 + 1; j <= y; j ++)
                  {
                        ans [ j - 1 ][ x1 -( j - y1 )] = '/';
                  }
            }
            else
            {
                  for( int j = y + 1; j <= y1; j ++)
                  {
                        ans [ j - 1 ][ x +( j - y - 1 )] = '\';
                  }
            }
      }
      int maxi = 0;
      int maxj = 0;
      repi( i , 0 , 1010)
      {
            repi( j , 0 , 1010)
            {
                  if( ans [ i ][ j ] != ' ')
                  {
                        maxi = max( i , maxi);
                        maxj = max( j , maxj);
                  }
            }
      }
      repi( i , 0 , maxi + 1)
      {
            repi( j , 0 , maxj + 1) printf( "%c" , ans [ i ][ j ]);
            cout << endl;
      }
//    for(pii temp:vals) cout << temp.ff <<" " << temp.ss << endl; cout << endl;
      return 0;
}

 

转载于:https://www.cnblogs.com/crazyacking/p/3762039.html

最后

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

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

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

评论列表共有 0 条评论

立即
投稿
返回
顶部