CF125D.Two progressions

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

An arithmetic progression is such a non-empty sequence of numbers where the difference between any two successive numbers is constant. This constant number is called common difference. For example, the sequence 3, 7, 11, 15 is an arithmetic progression. The definition implies that any sequences whose length equals 1 or 2 are arithmetic and all sequences whose length equals 0 are non-arithmetic.

You are given a sequence of different integers a1,a2,...,ana_{1},a_{2},...,a_{n} . You should either split it into two arithmetic progressions or find out that the operation is impossible to perform. Splitting assigns each member of the given sequence to one of two progressions, but the relative order of numbers does not change. Splitting is an inverse operation to merging.

输入格式

The first line contains a positive integer nn ( 2<=n<=300002<=n<=30000 ), nn is the length of the given sequence. The second line contains elements of the given sequence a1,a2,...,ana_{1},a_{2},...,a_{n} ( 108<=ai<=108-10^{8}<=a_{i}<=10^{8} ). The elements of the progression are different integers.

输出格式

Print the required arithmetic progressions, one per line. The progressions can be positioned in any order. Each progression should contain at least one number. If there's no solution, then print "No solution" (without the quotes)in the only line of the input file. If there are several solutions, print any of them.

输入输出样例

  • 输入#1

    6
    4 1 2 7 3 10
    

    输出#1

    1 2 3 
    4 7 10 
    
  • 输入#2

    5
    1 2 3 -2 -7
    

    输出#2

    1 2 3 
    -2 -7 
    

说明/提示

In the second sample another solution is also possible (number three can be assigned to the second progression): 1, 2 and 3, -2, -7.

首页