CF1934D2.XOR Break — Game Version

提高+/省选-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn, with players taking turns. On each turn of the game, the following sequence of events takes place:

  • The player having the integer pp breaks it into two integers p1p_{1} and p2p_{2}, where 0<p1<p0 \lt p_{1} \lt p, 0<p2<p0 \lt p_{2} \lt p and p1⊕p2=pp_{1} \oplus p_{2} = p.
  • If no such p1p_{1}, p2p_{2} exist, the player loses.
  • Otherwise, the opponent does either select the integer p1p_{1} or p2p_{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 6363 break operations. You have the choice to play first or second. The system will act for Bob.

Here ⊕\oplus denotes the bitwise XOR operation.

这是一个交互式问题。

这是该问题的游戏版本。请注意,本题的解法可能与单人版本的解法思路相同,也可能不同。你可以独立求解并分别获得两个版本的分数。

爱丽丝(Alice)和鲍勃(Bob)正在玩一个游戏。游戏开始时给定一个正整数 nn,双方轮流进行操作。在每一轮游戏中,将依次发生以下事件:

  • 当前持有整数 pp 的玩家将其拆分为两个整数 p1p_{1} 和 p2p_{2},满足 0<p1<p0 \lt p_{1} \lt p、0<p2<p0 \lt p_{2} \lt p,且 p1⊕p2=pp_{1} \oplus p_{2} = p。
  • 若不存在满足上述条件的 p1p_{1}、p2p_{2},则该玩家输掉游戏。
  • 否则,对手从 p1p_{1} 和 p2p_{2} 中任选其一。
  • 游戏以所选整数继续进行,对手将尝试对该整数进行拆分。

作为爱丽丝,你的目标是获胜。你最多可执行 6363 次拆分操作。你可以选择先手或后手。系统将代表鲍勃进行操作。

此处 ⊕\oplus 表示按位异或运算。

输入格式

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

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

每个测试包含多个测试用例。输入的第一行包含一个整数 tt(1≤t≤10001 \leq t \leq 1000),表示测试用例的数量。

每个测试用例仅一行,包含一个整数 nn(1≤n≤10181 \leq n \leq 10^{18}),表示游戏开始时的数字。

输入输出样例

  • 输入#1

    4
    1
    
    0 0
    3
    
    
    0 0
    13
    
    
    3 4
    
    0 0
    777777770001
    
    
    0 0

    输出#1

    second
    
    
    first
    2 1
    
    
    first
    10 7
    
    1 2
    
    
    first
    777777770000 1

说明/提示

Explanation for the interaction.

Interactor / Bob

Alice

Explanation

4

tt

1

nn for the first test case

second

Alice chooses to go second

0 0

Bob says he cannot break p=1p = 1

3

nn for the second test case

first

Alice chooses to go first

1 2

Alice breaks p=3p = 3 into p1=1p_1 = 1 and p2=2p_2 = 2

0 0

Bob says he cannot break p=1p = 1 or p=2p = 2

13

nn for the third test case

first

Alice chooses to go first

10 7

Alice breaks p=13p = 13 into p1=10p_1 = 10 and p2=7p_2 = 7

3 4

Bob breaks p=7p = 7 into p1=3p_1 = 3 and p2=4p_2 = 4

1 2

Alice breaks p=3p = 3 into p1=1p_1 = 1 and p2=2p_2 = 2

0 0

Bob says he cannot break p=1p = 1 or p=2p = 2

777777770001

nn for the fourth test case

first

Alice chooses to go first

777777770000 1

Alice breaks p=777 777 770 001p = 777\,777\,770\,001 into p1=777 777 770 000p_1 = 777\,777\,770\,000 and p2=1p_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 p1p_1 and perform a break operation but he gave up.

交互过程说明。

交互器 / Bob

Alice

说明

4

tt

1

第一个测试用例的 nn

second

Alice 选择后手

0 0

Bob 表示无法对 p=1p = 1 进行拆分

3

第二个测试用例的 nn

first

Alice 选择先手

1 2

Alice 将 p=3p = 3 拆分为 p1=1p_1 = 1 和 p2=2p_2 = 2

0 0

Bob 表示无法对 p=1p = 1 或 p=2p = 2 进行拆分

13

第三个测试用例的 nn

first

Alice 选择先手

10 7

Alice 将 p=13p = 13 拆分为 p1=10p_1 = 10 和 p2=7p_2 = 7

3 4

Bob 将 p=7p = 7 拆分为 p1=3p_1 = 3 和 p2=4p_2 = 4

1 2

Alice 将 p=3p = 3 拆分为 p1=1p_1 = 1 和 p2=2p_2 = 2

0 0

Bob 表示无法对 p=1p = 1 或 p=2p = 2 进行拆分

777777770001

第四个测试用例的 nn

first

Alice 选择先手

777777770000 1

Alice 将 p=777 777 770 001p = 777\,777\,770\,001 拆分为 p1=777 777 770 000p_1 = 777\,777\,770\,000 和 p2=1p_2 = 1

0 0

Bob 表示无法执行拆分操作。

本表格仅用于说明,不反映交互器的实际行为。

注意:在最后一个测试用例中,Bob 本可选择 p1p_1 并执行拆分操作,但他放弃了。

输入解题思路,AI测评打分。不知道怎么写?

首页