Codeforces Round 931 (Div. 2)
D2
XOR Break — Game Version
Codeforces
2400
原题
← D1E →
翻译中…

This is an interactive problem.

翻译中…

This is the game version of the problem. Note that the solution of this problem may or may not share ideas with the solution of the solo version. You can solve and get points for both versions independently.

翻译中…

Alice and Bob are playing a game. The game starts with a positive integer $n$, with players taking turns. On each turn of the game, the following sequence of events takes place:

翻译中…
  • The player having the integer $p$ breaks it into two integers $p_{1}$ and $p_{2}$, where $0 \lt p_{1} \lt p$, $0 \lt p_{2} \lt p$ and $p_{1} \oplus p_{2} = p$.
  • If no such $p_{1}$, $p_{2}$ exist, the player loses.
  • Otherwise, the opponent does either select the integer $p_{1}$ or $p_{2}$.
  • The game continues with the selected integer. The opponent will try to break it.
翻译中…

As Alice, your goal is to win. You can execute a maximum of $63$ break operations. You have the choice to play first or second. The system will act for Bob.

翻译中…

Here $\oplus$ denotes the bitwise XOR operation.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line of input contains a single integer $t$ ($1 \leq t \leq 1000$) — the number of test cases.

翻译中…

The only line of each test case contains a single integer $n$ ($1 \leq n \leq 10^{18}$) — the number the game starts with.

翻译中…

Interaction

翻译中…

For each test case, the interaction begins by reading the integer $n$.

翻译中…

After reading $n$, print a single line containing either "first" or "second", denoting what you want to play as (as first or second correspondingly).

翻译中…

On Alice's turn, you are required to print two positive integers, $p_{1}$ and $p_{2}$ such that $0 \lt p_{1} \lt p$, $0 \lt p_{2} \lt p$ and $p_{1} \oplus p_{2} = p$. Here, $p$ equals one of the two integers printed by Bob in the previous turn. If no turn has occurred previously, $p$ is equal to $n$. If Alice cannot perform a break operation, print "0 0" to receive a Wrong answer verdict.

翻译中…

On Bob's turn, you should read two integers, $p_{1}$ and $p_{2}$ such that $0 \lt p_{1} \lt p$, $0 \lt p_{2} \lt p$ and $p_{1} \oplus p_{2} = p$. Here, $p$ equals one of the two integers printed by Alice in the previous turn. If no turn has occurred previously, $p$ is equal to $n$. If Bob cannot perform a break operation $p_{1} = 0$ and $p_2 = 0$ in which case you should proceed to the next test case.

翻译中…

If any break operation performed by Alice is invalid, the interactor prints "-1 -1" and your code should promptly exit to receive a wrong answer verdict.

翻译中…

If Alice performs $63$ turns and Bob can still execute a break operation on the current integers, the interactor prints "-1 -1", and your code should promptly exit to receive a wrong answer verdict.

翻译中…

After printing a query, do not forget to output the end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:

翻译中…
  • fflush(stdout) or cout.flush() in C++;
  • System.out.flush() in Java;
  • flush(output) in Pascal;
  • stdout.flush() in Python;
  • see the documentation for other languages.
翻译中…

In this problem, hacks are disabled.

翻译中…

Note

翻译中…

Explanation for the interaction.

翻译中…
Interactor / Bob Alice Explanation
4 $t$
1 $n$ for the first test case
second Alice chooses to go second
0 0 Bob says he cannot break $p = 1$
3 $n$ for the second test case
first Alice chooses to go first
1 2 Alice breaks $p = 3$ into $p_1 = 1$ and $p_2 = 2$
0 0 Bob says he cannot break $p = 1$ or $p = 2$
13 $n$ for the third test case
first Alice chooses to go first
10 7 Alice breaks $p = 13$ into $p_1 = 10$ and $p_2 = 7$
3 4 Bob breaks $p = 7$ into $p_1 = 3$ and $p_2 = 4$
1 2 Alice breaks $p = 3$ into $p_1 = 1$ and $p_2 = 2$
0 0 Bob says he cannot break $p = 1$ or $p = 2$
777777770001 $n$ for the fourth test case
first Alice chooses to go first
777777770000 1 Alice breaks $p = 777\,777\,770\,001$ into $p_1 = 777\,777\,770\,000$ and $p_2 = 1$
0 0 Bob says he cannot perform break operation.
翻译中…

This table is for explanation only and does not reflect the actual behavior of the interactor.

翻译中…

Note that in the last test case Bob could choose $p_1$ and perform a break operation but he gave up.

翻译中…

样例

Input #1
4
1

0 0
3

0 0
13

3 4

0 0
777777770001

0 0
Output #1
second

first
2 1

first
10 7

1 2

first
777777770000 1
InputCopy OutputCopy
题目信息
题号
1934D2
时间限制
3 s
内存限制
256 MB
标签
位运算
博弈论
贪心
交互题

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。