#P15542. [CCC 2026 S3] Common Card Choice

[CCC 2026 S3] Common Card Choice

Description

There are NN cards with positive integers written on them. Alice takes some of the cards, then Bob takes some of the remaining cards. Both need to take at least one card; Alice is not allowed to take all of the cards. Then Alice and Bob compute the sum of numbers on the cards that they have taken. If these sums have a common divisor greater than one, Alice and Bob get a bag of sweets; otherwise they don't. Given the cards on the table, determine if it is possible for Alice and Bob to get the sweets, and if so, how.

To make it even more challenging, in some cases, neither Alice nor Bob knows any of the values on the cards.

Note that an integer dd is a divisor of an integer qq if there is no remainder when qq is divided by dd. An integer zz is a common divisor of integers xx and yy if zz is a divisor of both xx and yy.

Input Format

The first line of input contains NN (2N1052 \le N \le 10^5).

The second line contains NN integers, cic_i (1ci10121 \le c_i \le 10^{12}).

Output Format

On the first line of output, print YES if it is possible to get the sweets, otherwise, print NO.

If the answer is YES, on the second line of output, produce AA, the number of cards that Alice should take, followed by one space, followed by BB, the number of cards that Bob should take. On the third line of output, print out AA space-separated numbers corresponding to the indices of the cards that Alice should take. On the fourth line of output, print out BB space-separated numbers corresponding to the indices of the cards that Bob should take. If there are several ways to select cards, print any of them.

If the input is for the last subtask, output an integer K100K \le 100 on the first line, followed by KK possible combinations of output as specified for all other subtasks. That is, each combination will be the same sequence of three lines as stated above: one line containing AA and BB; one line containing AA indices of cards; and one line containing BB indices of cards. All guesses of indices of cards must be disjoint: that is, no card index can appear in more than one guess. Your output will be judged correct if any of the combinations would result in Alice and Bob obtaining a bag of sweets. Note that you will not receive any feedback between guesses.

7
19 7 11 31 99 13 17
YES
3 3
2 3 7
4 6 1
3
3 11 17
NO
100000
-1 -1 -1 ...

2
1 2
1
3 5
3 2
100 101 102
201 200

Hint

Explanation of Output for Sample Input 1

The sum of Alice’s cards is 7+11+17=357 + 11 + 17 = 35 and the sum of Bob’s cards is 31+13+19=6331 + 13 + 19 = 63, and both 3535 and 6363 are divisible by 77.

Explanation of Output for Sample Input 2

Notice that 33, 1111, and 1717 have no common divisors, and all possible sums of two of these numbers (1414, 2020, 2828) do not have a common factor with the remaining third number.

Explanation of Output for Sample Input 3

There are a total of two guesses. The first guess consists of indices {1}\{1\} and {3,5}\{3, 5\}. The second guess consists of indices {100,101,102}\{100, 101, 102\} and {201,200}\{201, 200\}.

Note that all sets of indices are disjoint.

Although the output is formatted correctly, the output will receive Wrong answer because the two guesses are not enough for Alice and Bob to obtain a bag of sweets.

The following table shows how the 15 available marks are distributed:

Marks Awarded Bounds on NN Bounds on cic_i
2 marks 2N32 \le N \le 3 1ci1001 \le c_i \le 100
1 marks 2N102 \le N \le 10
2N1052 \le N \le 10^5 1ci21 \le c_i \le 2
2 marks 1ci1051 \le c_i \le 10^5
1ci10121 \le c_i \le 10^{12}
7 marks N=105N = 10^5 ci=1c_i = -1 and see Note below

Note: For the last subtask, you will be given NN, but all NN card values will be labelled with 1-1, indicating that those card values are unknown to you. In this last subtask, there will always be a selection of cards that Alice and Bob can pick to obtain a bag of sweets.