CF2246E.lce4113 and Security Game
省选/NOI-
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an interactive problem. Additionally, hacks are disabled for this problem.
There are two hidden integers b and v such that b∈0,1 and 0≤v<230. There is also a hidden operation ty, which is either & or ∣. Here, & denotes the bitwise AND operation. Additionally, ∣ denotes the bitwise OR operation.
Your goal is to guess b.
The interaction proceeds as follows:
- First, you send a value x to the interactor, such that 0≤x<230.
- The interactor sends back vtyx. Formally, it will send back o(v,x), where $$o(v,x) = \begin{cases}v\,\&\,x & \mathrm{ty} = \& \\ v\,|\,x & \mathrm{ty} = |.\end{cases}$$
- You then send two numbers m0 and m1, where 0≤m0,m1<230.
- Finally, the interactor will send back mb⊕v, where ⊕ denotes the bitwise XOR operation.
After the interaction, you have to output b.
这是一个交互式问题。此外,本题禁用 hack 功能。
存在两个隐藏整数 b 和 v,满足 b∈{0,1} 且 0≤v<230。还存在一个隐藏运算符 ty,其值为 & 或 ∣。其中,& 表示按位与运算,而 ∣ 表示按位或运算。
你的目标是猜出 b 的值。
交互流程如下:
- 首先,你向交互器发送一个值 x,满足 0≤x<230。
- 交互器返回 vtyx。形式化地,它将返回 o(v,x),其中
o(v,x)={v&xv∣xty=&ty=∣.
- 接着,你发送两个数 m0 和 m1,满足 0≤m0,m1<230。
- 最后,交互器返回 mb⊕v,其中 ⊕ 表示按位异或运算。
交互结束后,你需要输出 b。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤105). The description of the test cases follows. Note that this is the only initial input given.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤105)。随后是测试用例的描述。注意,这是唯一给出的初始输入。
输出格式
null
输入输出样例
输入#1
3 0 315 3 35 5 5
输出#1
2 314 159 0 3 12 34 1 0 0 0 1
说明/提示
The example interaction proceeds as follows:
Solution
Interactor
Explanation
3
There are 3 test cases.
2
The solution chooses x=2.
0
The interactor sends back xtyv=2&1=0.
314 159
The solution sends m0=314 and m1=159.
315
The interactor responds with mb⊕v=m0⊕v=315.
0
The solution determines b=0.
3
The next test case begins. The solution chooses x=3.
3
The interactor sends back xtyv=3∣1=3.
12 34
The solution sends m0=12 and m1=34.
35
The interactor responds with mb⊕v=m1⊕v=35.
1
The solution determines b=1.
0
The final test case begins. The solution chooses x=0.
5
The interactor sends back xtyv=0∣5=5.
0 0
The solution sends m0=0 and m1=0.
5
The interactor responds with mb⊕v=m1⊕v=5.
1
The solution determines b=1.
Note that the queries made by the example solution may not yield enough information to determine the hidden bit b. Additionally the empty lines in the example interaction are given for readability and need not be outputted in the solution.
The hidden values in the test cases are given below.
Test #
v
b
ty
1
1
0
&
2
1
1
∣
3
5
1
∣
示例交互过程如下:
解答
交互器
说明
3
共有 3 个测试用例。
2
解答选择 x=2。
0
交互器返回 xtyv=2&1=0。
314 159
解答发送 m0=314 和 m1=159。
315
交互器响应 mb⊕v=m0⊕v=315。
0
解答判定 b=0。
3
下一个测试用例开始。解答选择 x=3。
3
交互器返回 xtyv=3∣1=3。
12 34
解答发送 m0=12 和 m1=34。
35
交互器响应 mb⊕v=m1⊕v=35。
1
解答判定 b=1。
0
最后一个测试用例开始。解答选择 x=0。
5
交互器返回 xtyv=0∣5=5。
0 0
解答发送 m0=0 和 m1=0。
5
交互器响应 mb⊕v=m1⊕v=5。
1
解答判定 b=1。
注意:示例解答所作的查询可能不足以确定隐藏比特 b。此外,示例交互中的空行仅为增强可读性,在实际解答中无需输出。
各测试用例中的隐藏值如下表所示:
测试编号
v
b
ty
1
1
0
&
2
1
1
∣
3
5
1
∣
输入解题思路,AI测评打分。不知道怎么写?