zoukankan      html  css  js  c++  java
  • cf435C 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

    又一模拟题。。。

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<cstring>
    #define ll long long 
    #define inf 0x7fffffff
    using namespace std;
    inline int read()
    {
        int x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x*=10;x+=ch-'0';ch=getchar();}
        return x*f;
    }
    int n,tot,mx=1000,mn=1000,x,y=1000;
    int a[1005];
    int b[2005][2005];
    int main()
    {
        n=read();
        for(int i=1;i<=n;i++)
            a[i]=read(),tot+=a[i];
        for(int i=1;i<=n;i++)
        {
            x++;
            if(i&1)
            {
                a[i]--;
                b[x][y]=1;
                while(a[i]--)
                {
                    x++;y++;
                    b[x][y]=1;
                }
                mx=max(mx,y);
            }
            else 
            {
                a[i]--;
                b[x][y]=2;
                while(a[i]--)
                {
                    x++;y--;
                    b[x][y]=2;
                }
                mn=min(mn,y);
            }
        }
        for(int i=mx;i>=mn;i--)
        {
            for(int j=1;j<=tot;j++)
                if(b[j][i]==1)printf("/");
                else if(b[j][i]==2)printf("\");
                else printf(" ");
            printf("
    ");
        }
        return 0;
    }
    
    ——by zhber,转载请注明来源
  • 相关阅读:
    超简单解释TCP、UDP、HTTP
    亲身经历面试题总结
    面试最让你手足无措的一个问题:你的系统如何支撑高并发?
    什么是hadoop,hadoop可以做什么
    在.net Core中如何使用HTML5上传视频
    2018很废的一年
    SQL合集
    ASP.NET CORE 基础配置、Linux发包
    SQL获取本周,上周,本月,上月的开始时间和结束时间
    C# net Emgu.CV.World 人脸识别 根据照片将人脸抠图出来。
  • 原文地址:https://www.cnblogs.com/zhber/p/4035974.html
Copyright © 2011-2022 走看看