CF1867E1.Salyg1n and Array (simple version)
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is the simple version of the problem. The only difference between the versions is the limit on the number of queries. In this version, you can make no more than 100 queries. You can make hacks only if both versions of the problem are solved.
This is an interactive problem!
salyg1n has given you a positive integer k and wants to play a game with you. He has chosen an array of n integers a1,a2,…,an (1≤ai≤109). You must print a1⊕a2⊕…⊕an, where ⊕ denotes the bitwise XOR operation. You can make queries of the following type:
- ? i: in response to this query, you will receive ai⊕ai+1⊕…⊕ai+k−1. Also, after this query, the subarray ai,ai+1,…,ai+k−1 will be reversed, i.e., the chosen array a will become: a1,a2,…ai−1,ai+k−1,ai+k−2,…,ai+1,ai,ai+k,…,an.
You can make no more than 100 queries to answer the problem.
这是该问题的简单版本。两个版本之间的唯一区别在于查询次数的限制。在本版本中,你最多可以进行 100 次查询。仅当该问题的两个版本均被解决时,才允许进行 hack。
这是一个交互式问题!
salyg1n 给了你一个正整数 k,并想和你玩一个游戏。他选择了一个由 n 个整数组成的数组 a1,a2,…,an(其中 1≤ai≤109)。你需要输出 a1⊕a2⊕…⊕an,其中 ⊕ 表示按位异或运算。你可以进行如下类型的查询:
- ? i:对于该查询,你将收到 ai⊕ai+1⊕…⊕ai+k−1 的值。此外,在该查询之后,子数组 ai,ai+1,…,ai+k−1 将被翻转,即原数组 a 将变为:
a1,a2,…,ai−1,ai+k−1,ai+k−2,…,ai+1,ai,ai+k,…,an。
你最多可进行 100 次查询来解答该问题。
输入格式
The first line contains a single integer t (1≤t≤1000) – the number of test cases.
第一行包含一个整数 t(1≤t≤1000)——测试用例的数量。
输入输出样例
输入#1
2 4 2 6 4 6 6 4
输出#1
? 1 ? 3 ! 2 ? 1 ! 4
说明/提示
In the first test case, the jury has chosen the array a = [4,2,5,1]
In the second test case, the jury has chosen the array a = [5,7,1,3,3,7]
在第一个测试用例中,出题人选择的数组为 a = [4,2,5,1]。
在第二个测试用例中,出题人选择的数组为 a = [5,7,1,3,3,7]。
输入解题思路,AI测评打分。不知道怎么写?