zoukankan      html  css  js  c++  java
  • ural 1904(超级难读懂的题意)

    题意太难读懂。 读懂了就是水题了

    E - The Lessons of the Past
    Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

    Description

    It was the middle of the 23rd century. Alien creatures suddenly came out from hyperspace and attacked the Twenty-fifth colonization mission just when all its members gathered in a concert of one of the most popular singers in the whole Galaxy. Nearly a third of all mission members died during the ensuing panic and chaos.
    Since then control of hyperspace has become one of the highest priorities of the Defense Forces. Automatic drones with hyperspace field vibration amplitude sensors were sent to the farthest corners of the inhabited part of the Galaxy. However, collecting data from them turned out to be a quite complicated technical problem. The point is that a huge amount of energy is required to transmit data at such distances without distortion. Even the usage of intermediary retransmitters doesn’t improve the situation much. However, engineers managed to find a sufficiently elegant solution. The retransmitter sends not the measured value, but an absolute value of the difference between the measured value and some reference value, which is imprinted in the memory of this retransmitter. These reference numbers are chosen in such a way that for the normal vibration level detected by sensor the final retransmitter in chain should send a number that is close to zero. So, when the final retransmitter sends the number that is strictly greater than one, the hyperspace disturbance is assumed to have happened. Security experts are interested how reliable the system of k retransmitters is, and what range of sensor readings will be interpreted as a calm state of hyperspace field. You are delegated to study this question.

    Input

    The first line contains an integer k that is the total number of retransmitters (1 ≤ k ≤ 10). The second line contains integers a1, …, ak that are the reference values recorded in the memory of retransmitters in the order the signal follows from the hyperspace field sensor to the receiver on the scout ship (−1000 ≤ ai ≤ 1000).

    Output

    In the first line output the integer n that is the amount of segments in answer. In the i'th of the following n lines output integers li ≤ ri that are the bounds of the i'th segment. The segments must be output in the ascending order of coordinates and without mutual intersections.

    Sample Input

    inputoutput
    3
    0 4 2
    
    4
    -7 -5
    -3 -1
    1 3
    5 7
    
    #include <stdio.h>
    #include <string.h>
    #include <math.h>
    #include <algorithm>
    #include <iostream>
    using namespace std;
    
    int mark[200100];
    
    struct node
    {
        int x,y;
    }edge[1010000];
    
    int g[20];
    int n;
    
    
    int fuc(int x)
    {
        int tmp=x;
        for(int i=1;i<=n;i++)
        {
            tmp=tmp-g[i];
            if(tmp<0) tmp*=-1;
        }
        if(tmp<=1) return 1;
        else return 0;
    }
    
    int main()
    {    
        while(~scanf("%d",&n))
        {
            int cnt=0;
            memset(mark,0,sizeof(mark));
            memset(edge,0,sizeof(edge));
            for(int i=1;i<=n;i++)
            {
                scanf("%d",&g[i]);
            }
            /*
            for(int i=-10000;i<=10000;i++)
            {
                if( fuc(i) )
                {
                    int j=i+1;
                    while(fuc(j))
                    {
                        j++;
                    }
                    edge[cnt].x=i;
                    edge[cnt].y=j-1;
                    cnt++;
                    i=j;
                }
            }
            
            printf("%d\n",cnt);
            for(int i=0;i<cnt;i++)
                printf("%d %d\n",edge[i].x,edge[i].y);
            */
            ///////////
            cnt=0;
            for(int i=-20000;i<=20000;i++)
            {
                if(fuc(i))
                {
                    mark[i+20000]=1;
                }
            }
            int flag=0;
            int b=0,d=0;
            for(int i=0;i<=40220;i++)
            {
                if(mark[i]==1&&flag==0)
                {
                    flag=1;
                    b=i;
                }
                else
                {
                    if(mark[i]==0&&flag==1)
                    {
                        flag=0;
                        d=i-1;
                        edge[cnt].x=b-20000;
                        edge[cnt].y=d-20000;
                        cnt++;
                    }
                }
            }
    
            printf("%d\n",cnt);
            for(int i=0;i<cnt;i++)
                printf("%d %d\n",edge[i].x,edge[i].y);
        }
        return 0;
    }
     
  • 相关阅读:
    Maven学习笔记
    [学习笔记] 网络流
    [Contest on 2021.11.3] 女子口阿
    [杂题合集] 25 岁小伙突然没了心跳,他的习惯很多年轻人都有!
    CSP 2021 提高组游记
    [题目小结] 可持久化数据结构
    [学习笔记] 无向图和有向图的连通分量
    [Contest on 2021.10.17] HustOJ 就是个 **
    [Contest on 2021.10.15] 细思极恐
    妖怪寺外,灯火通明
  • 原文地址:https://www.cnblogs.com/chenhuan001/p/3094189.html
Copyright © 2011-2022 走看看