One Number Hint
Time limit1sMemory limit256 MB
Implement two fixed rules over 6-element subsets of 1 to 12: output the smallest element in S(x) missing from S(y), and answer yes when h lies in S(q).
- Level
Easy3 of 10
- Topics
- Combinatorics, Implementation
- Solved
- No attempts yet
Problem
A and B want to get into a locked research laboratory. The entrance runs a security system that asks one question. The question is written as an integer with , and it must be answered with either yes or no. A correct answer opens the door, and a wrong answer sets off the alarm.
Both of them know that is always either or , where , the correct answer to is yes, and the correct answer to is no.
While they were planning, neither could recall the actual values of and . So B walks up to the entrance alone and A waits far away. The moment the question appears, A remembers and . From that distance A cannot explain anything to B. A can only shout one integer . Everything B needs has to fit into that single .
Write a program that plays both parts. In the first run it reads , , and prints the number that A shouts. In the second run it reads , , and prints the answer B should give.
The two runs are judged separately, so the rule that turns into and the rule that turns into an answer are both fixed here.
The subset table. Take every 6-element subset of , write each subset as its elements in increasing order, and sort those sequences lexicographically. There are 924 such subsets. Let be the -th subset in this order, counting from 1. The first four are , , and , and the last one is .
The number A shouts. For a pair , is the smallest number that belongs to and not to . Two different subsets of the same size never contain one another, so such a number always exists.
The answer B gives. For a pair , the answer is yes if , and no otherwise.
Input
The first line contains a single integer, either 1 or 2.
If it is 1, the program plays A. The second line contains and . The -th of the next lines contains and (, ).
If it is 2, the program plays B. The second line contains and . The -th of the next lines contains and (, ).
Output
If the program plays A, print lines. The -th line holds the number for test case , computed by the rule above.
If the program plays B, print lines. The -th line holds the answer for test case , computed by the rule above, written as yes or no.
Constraints
In every test case and .