#P9575. 「TAOI-2」喵了个喵 Ⅳ
「TAOI-2」喵了个喵 Ⅳ
Background
Xiao S has a total of cute cats. The -th cat has cuteness . Xiao S wants to split his cats into two groups. Considering that Xiao S's cats are not like some cats that have nine lives, each of his cats has only one life, so a cat cannot be put into both groups at the same time (please do not try to imagine this scene). Also, if a cat is not assigned to any group, it will be very angry, and it may very likely cause Xiao S to suffer from insomnia.
Of course, Xiao S also hopes that the two groups have the same group cuteness. That is, there exists a positive integer such that the sum of in one group equals the sum of in the other group. Please determine whether Xiao S can split the cats into two groups, and whether you can find an that makes the group cuteness of the two groups equal.
Problem Description
Given a positive integer and a sequence of positive integers, please partition into two sets and give a positive integer such that . If there is no solution, output .
You need to guarantee . It is guaranteed that under this problem's Constraints, if a solution exists then there is always a solution with .
Input Format
The first line contains one positive integer .
The next line contains positive integers, where the -th one denotes .
Output Format
If there is no solution, output a single line with the integer . Otherwise:
The first line outputs one positive integer .
The second line outputs a string of length . The -th character is meaning that is placed into set , and meaning that is placed into set .
3
1 1 1
-1
4
4 1 2 3
3
0001
Hint
This problem uses bundled testdata.
- Subtask 0 (2 pts): is even.
- Subtask 1 (8 pts): all are odd.
- Subtask 2 (15 pts): , .
- Subtask 3 (25 pts): , .
- Subtask 4 (50 pts): no special restrictions.
For all testdata, , .
Translated by ChatGPT 5