zoukankan      html  css  js  c++  java
  • URAL 1944 大水题模拟

    D - Record of the Attack at the Orbit
    Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

    Description

    The long-range laser at the board of combat spaceship “Rickenbacker” had successfully destroyed all the launching pads on the surface of enemy planet Orkut. Within less than a day, race Shodan had surrendered.
    The captain of “Rickenbacker” expected a promotion. His enviers, in their turn, were trying to persuade the high command that the captain was a liar—no one is able to be so quick on the uptake and to strike so many targets during an attack at the orbit. The captain understood that he was to defend his honour and prepare a detailed report on the mission accomplished. For a start, he decided to draw all the destroyed pads on one graph.
    The laser direction system is bound to a rectangular Cartesian coordinates. All the coordinates of the destroyed pads in these coordinates are integers. Axes should be depicted with symbols “|” (vertical slash, to show the y-axis), “-” (minus, to show the x-axis), “+” (plus, to show the origin). Spots where the destroyed pads were situated should be depicted with symbol “*” (asterisk). All the other points should be depicted with symbol “.” (dot). The x-axis in the graph should be directed to the right, and the y-axis should be directed upwards. One symbol in the graph corresponds to one unit on the x-axis horizontally and to one unit on the y-axis vertically. The axes should be depicted in the graph, but they may be completely covered with symbols “*”.

    Input

    The first line contains an integer n (1 ≤ n ≤ 250) that is the number of destroyed launching pads. Each of the following n lines contains coordinates of one pad. All the coordinates are integers not exceeding 100 by absolute value. No two pads are situated at the same point.

    Output

    Output the required graph. The first line should correspond to the maximum value of y (or 0), and the last one should correspond to the minimum value of y (or 0). Each line should have the same amount of symbols. The first symbol in the line should correspond to the minimum value of x (or 0) and the last one should correspond to the maximum value of x (or 0).

    Sample Input

    inputoutput
    8
    -10 5
    -7 3
    -4 2
    -9 4
    0 1
    6 -1
    3 0
    8 -3
    
    *.........|........
    .*........|........
    ...*......|........
    ......*...|........
    ..........*........
    ----------+--*-----
    ..........|.....*..
    ..........|........
    ..........|.......*
    #include<stdio.h>
    #include<string.h>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    char Map[1000][1000];
    struct node{
      int x,y;
    
    }que[1000];
    bool cmp1(struct node t1,struct node t2){
    
      return t1.x<t2.x;
    }
    
    bool cmp2(struct node t1,struct node t2){
    
      return t1.y>t2.y;
    }
    
    int main(){
      int n;
      while(scanf("%d",&n)!=EOF){
    
         for(int i=0;i<=550;i++)
        for(int j=0;j<=550;j++)
        Map[i][j]='.';
    
        for(int i=0;i<=500;i++){
            Map[i][200]='-';
            Map[200][i]='|';
        }
        Map[200][200]='+';
        for(int i=0;i<n;i++){
    
            scanf("%d%d",&que[i].x,&que[i].y);
                  int tx=que[i].x+200;
                  int ty=que[i].y+200;
    
            Map[tx][ty]='*';
    
        }
        int x1,x2,y1,y2;
        sort(que,que+n,cmp1);
         x1=que[0].x+200;
           x2=que[n-1].x+200;
       sort(que,que+n,cmp2);
        y1=que[0].y+200;
         y2=que[n-1].y+200;
         if(y1>200&&y2>200)
            y2=200;
        else if(y1<200&&y2<200)
            y1=200;
         if(x1>200&&x2>200)
            x1=200;
       else  if(x1<200&&x2<200)
            x2=200;
        for(int i=y1;i>=y2;i--){
                for(int j=x1;j<=x2;j++){
               printf("%c",Map[j][i]);
                }
                printf("
    ");
            }
    
      }
      return 0;
    }
  • 相关阅读:
    C语言中的内存分配与释放
    CentOS下Mysql安装教程
    简单的理解deflate算法
    Memcache的一些学习
    Python学习入门基础教程(learning Python)--6.4 Python的list与函数
    Delphi Windows API判断文件共享锁定状态(使用OpenFile来判断)
    深刻:截获windows的消息并分析实例(DefWindowProc),以WM_NCHITTEST举例(Windows下每一个鼠标消息都是由 WM_NCHITTEST 消息产生的,这个消息的参数包含了鼠标位置的信息)
    WM_SYSCOMMAND消息命令整理 good
    Delphi 中 FindWindow 和 FindWindowEx 找到外部进程,然后发送消息(比如最大化)
    再来一个学历,理论与动手能力的讨论——结论是理论和实际都重要,但是上学期间应偏重理论
  • 原文地址:https://www.cnblogs.com/13224ACMer/p/4686970.html
Copyright © 2011-2022 走看看