#P4459. [BJOI2018] 双人猜数游戏
[BJOI2018] 双人猜数游戏
Description
Alice and Bob are very smart; they can figure out optimal strategies for all kinds of games. A variety show "The Strongest Boss" invites them to play a game. The host writes three positive integers , then tells Alice and Bob together that and what is. (That is, is the lower bound for the to be guessed.) Then the host privately tells Alice what is, and privately tells Bob what is.
Of course, if one person knows both and , they can easily compute and , but now Alice and Bob each know only one of them, and they can only answer the host’s questions without communicating. Starting from one of them, the host alternately asks the current respondent, “Do you know what and are?” The respondent can only answer “know” or “don’t know.”
For show effects and to demonstrate Alice and Bob’s brilliance, the host wants that after a total of “don’t know” answers, both Alice and Bob will know what and are. Now the host asks you to construct a pair and that satisfies the requirements.
Input Format
A single line in the form s <name> t (where <name> is Alice or Bob), where is the lower bound for the numbers to guess, <name> is the person the host asks first, and is the total number of “don’t know” answers from Alice and Bob.
Output Format
Output two integers and (separated by a space), representing one valid solution. If there are multiple solutions, output the one with the smallest . If there are still multiple, among those with minimal , output the one with the smallest .
5 Bob 2
6 10
2 Alice 3
4 4
Hint
Sample 1 Explanation
The host tells Alice and Bob that , privately tells Alice , and privately tells Bob . The questioning process:
- The host asks Bob; Bob says “don’t know.”
- The host asks Alice; Alice says “don’t know.”
- The host asks Bob; Bob says “know.”
- The host asks Alice; Alice says “know.”
Sample 2 Explanation
The host tells Alice and Bob that , privately tells Alice , and privately tells Bob . The questioning process:
- The host asks Alice; Alice says “don’t know.”
- The host asks Bob; Bob says “don’t know.”
- The host asks Alice; Alice says “don’t know.”
- The host asks Bob; Bob says “know.”
- The host asks Alice; Alice says “know.”
Constraints and Conventions
- For of the testdata, .
- For of the testdata, , , and a solution exists.
Translated by ChatGPT 5
京公网安备 11011102002149号