题库练习 Two progressions
← 上一题 下一题 →

A8329 | Two progressions

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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 $a_{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 $n$ ( $2<=n<=30000$ ), $n$ is the length of the given sequence. The second line contains elements of the given sequence $a_{1},a_{2},...,a_{n}$ ( $-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 
C++ 编辑器
输入
输出