#P13725. [GCPC 2024] Jigsaw Present

    ID: 15556 远端评测题 5000ms 1024MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>2024Special JudgeICPC折半搜索 meet in the middle

[GCPC 2024] Jigsaw Present

题目描述

Julia is preparing a present for James. She will give him some of her nn jigsaw puzzles, where puzzle ii (1in1 \leq i \leq n) consists of xix_i pieces and has a difficulty yiy_i (can be negative if the puzzle is very easy).

James is already very excited and would like to know in advance what he will get. Therefore, he used some of his criminal energy to gather information about the gift. In particular, he has managed to obtain an encrypted message containing the total difficulty and total number of pieces of all the puzzles that he will receive.

Now he wonders whether it is worth spending some more time to decrypt the message. After all, it might be that this information is not enough to uniquely determine his gift. Since he was never good at these computer thingies, James asked for your assistance. Help him find out whether it is worth decrypting the message or not. If the answer is negative, you have to find two distinct gifts that result in the same encrypted message.

输入格式

The input consists of

  • One line with an integer nn (2n40962 \leq n \leq 4\,096), the number of puzzles that Julia owns.
  • nn lines, the iith of which contains two integers xix_i and yiy_i (1xi40961 \leq x_i \leq 4\,096, yi4096\left|y_i\right| \leq 4\,096), the number of pieces of puzzle ii and the difficulty of puzzle ii.

输出格式

If James can uniquely determine his gift, then print "yes\texttt{yes}". Otherwise, you should print "no\texttt{no}" followed by two lines, where each line contains the description of a present. The description of a present should start with an integer kk, the number of puzzles, followed by kk distinct integers, the indices of the puzzles.

Note that the two presents have to be distinct, meaning that there should be at least one puzzle that is contained in one present but not the other.

If there are multiple presents that result in the same encrypted message, you can print any of them.

5
2 -1
3 2
3 1
1 -3
1 1
no
3 2 4 5
2 1 3
4
2 -1
3 2
3 1
1 -3
yes

提示

In the first sample case, the first present consists of puzzles 22, 44, and 55. The total number of pieces is 3+1+1=53 + 1 + 1 = 5 and the total difficulty is 2+(3)+1=02 + (-3) + 1 = 0. The second present consists of puzzles 11 and 33. The total number of pieces is 2+3=52 + 3 = 5 and the total difficulty is (1)+1=0(-1) + 1 = 0. Thus, if James only knows the total number of pieces and the total difficulty, he cannot recover his present. So it is not worth to decode the message.

In the second sample case, no matter what gift Julia prepares, if James knows the total number of pieces and the total difficulty, he can recover his present. So he should decode the message.