21105_Empodia

2022-5-16 18:18| 发布者: Hocassian| 查看: 51| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504845111199-Problem List-采集的数据-后羿采集器.html

Pro.ID

21105

Title

Empodia

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21105

AC

0

Submit

8

Ratio

0.00%

时间&空间限制

  • Time Limit: 6000/2000 MS (Java/Others)     Memory Limit: 262144/131072 K (Java/Others)
  • 描述

    The ancient mathematician and philosopher Pythagoras believed that reality is mathematical in nature. Present-day biologists study properties of biosequences. A biosequence is a sequence of M integers, which 
    • contains each of the numbers 0,1,...,M 1,
    • starts with 0 and ends with M 1, and
    • has no two elements E,E+1 in adjacent positions in this order.

    A subsequence consisting of adjacent elements of a biosequence is called a segment 
    A segment of a biosequence is called a framed interval if it includes all integers whose values are between the value of the first element, which must be the smallest element in the segment, and the last element, which must be the largest and different from the first. A framed interval is called an empodio if it does not contain any shorter framed intervals. 

    As an example, consider the biosequence (0,3,5,4,6,2,1,7). The whole biosequence is a framed interval. However, it contains another framed interval (3,5,4,6) and therefore it is not an empodio. The framed interval (3,5,4,6) does not contain a shorter framed interval, so it is an empodio. Furthermore, it is the only empodio in that biosequence. 

    You are to write a program that, given a biosequence, finds all empodia (plural for empodio) in that biosequence.

    输入

    The first line contains a single integer M: the number of integers in the input biosequence. The following M lines contain the integers of the biosequence in the order of the sequence. Each of these M lines contains a single integer.

    In one input, 1000000≤M≤1100000. In all other inputs, 1≤M≤60000. 
    Additionally, in 50% of the inputs, M≤2600.

    输出

    Description
    The ancient mathematician and philosopher Pythagoras believed that reality is mathematical in nature. Present-day biologists study properties of biosequences. A biosequence is a sequence of M integers, which 
    • contains each of the numbers 0,1,...,M 1,
    • starts with 0 and ends with M 1, and
    • has no two elements E,E+1 in adjacent positions in this order.

    A subsequence consisting of adjacent elements of a biosequence is called a segment 
    A segment of a biosequence is called a framed interval if it includes all integers whose values are between the value of the first element, which must be the smallest element in the segment, and the last element, which must be the largest and different from the first. A framed interval is called an empodio if it does not contain any shorter framed intervals. 

    As an example, consider the biosequence (0,3,5,4,6,2,1,7). The whole biosequence is a framed interval. However, it contains another framed interval (3,5,4,6) and therefore it is not an empodio. The framed interval (3,5,4,6) does not contain a shorter framed interval, so it is an empodio. Furthermore, it is the only empodio in that biosequence. 

    You are to write a program that, given a biosequence, finds all empodia (plural for empodio) in that biosequence.
    Input

    The first line contains a single integer M: the number of integers in the input biosequence. The following M lines contain the integers of the biosequence in the order of the sequence. Each of these M lines contains a single integer.

    In one input, 1000000≤M≤1100000. In all other inputs, 1≤M≤60000. 
    Additionally, in 50% of the inputs, M≤2600.

    Output
    The first line in this file is to contain one integer H: the number of empodia in the input biosequence. The following H lines describe all empodia of the input biosequence in the order of appearance of the starting point in the biosequence. Each of these lines is to contain two integers A and B (in that order) separated by a space, where the Ath element of the input biosequence is the first element of the empodio and the Bth element of the input biosequence is the last element of the empodio.
    Sample Input
    8
    0
    3
    5
    4
    6
    2
    1
    7
    Sample Output
    1
    2 5
    Source

    样例输入

    8
    0
    3
    5
    4
    6
    2
    1
    7

    样例输出

    1
    2 5

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部