## COCI '19 Contest 3 #3 Drvca

View as PDF

Points: 15 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem types
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Advent in Zagreb is a traditional holiday manifestation whose main attraction is a magical Christmas market located at the city centre. It should also be noted that this event was voted the best in Europe for three years in a row. Apart from travelling fast, good news also has the tendency to travel far. Indeed, the information about Advent in Zagreb reached North Pole and Santa Claus himself. Interestingly enough, Santa never visited Croatia (except for usual business on Christmas Eve). When you think about it, that makes sense since he doesn't really like summer activities by the sea and he can solve COCI problems from the comfort of his own home.

Luckily, he decided to visit our Christmas market so he sent a letter to the town hall stating that he will land on Zagreb's main square in the early morning of December . After his on-site participation in a COCI round, he will have a guided tour of Zagreb's finest gastronomic sites by Mr. Malnar.

You are probably wondering: "How exactly does Santa plan to land, there is no runway there!". You are right, there is not, but we'll manage. The town hall already prepared Christmas trees that should be featured on the main square. Now, they will simply take those trees and place them in two rows which will define the boundaries of the runway. For some reason they want to make the absolute difference in height between each two neighbouring trees to be the same in each row. Moreover, they want to have the trees sorted in each row from the shortest to the highest. Help them divide the trees into two rows that satisfy these conditions.

#### Input

The first line contains an integer from the task description.

The next line contains integers that denote the heights of all Christmas trees.

#### Output

In the first line you should output an integer which represents the number of trees in the first row.

In the second line you should output integers which represent the heights of the trees in the first row of the runway.

In the third line you should output an integer which represents the number of trees in the second row.

In the fourth line you should output integers which represent the heights of the trees in the second row of the runway.

The rows are not allowed to be empty and and each tree should be a part of one row . Also, trees should be sorted in each row from the shortest to the highest. If there are multiple solutions, you can output any of them. If there is no solution which satisfies the necessary conditions, you should output in the only line of output.

#### Scoring

, there is a solution in which both rows have the same number of trees.

#### Sample Input 1

4
1 3 2 4

#### Sample Output 1

2
1 2
2
3 4

#### Sample Input 2

6
23 4 7 6 8 15

#### Sample Output 2

3
4 6 8
3
7 15 23

#### Sample Input 3

6
1 2 3 7 9 10

#### Sample Output 3

-1