QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 256 MB 満点: 100

#12104. Xoractive

統計

Aidos 想出了一个谜题并挑战 Temirulan 去解决它。他选择了一个包含 $n$ 个不同的非负整数的序列 $a$,编号从 $1$ 到 $n$:$a_1, a_2, \dots, a_n$。

Temirulan 可以询问两种类型的问题:

  • ask — 揭示给定序列中位置 $i$ 处的数字。
  • get_pairwise_xor — 对于给定的不同整数序列:$i_1, i_2, \dots, i_k$,获取序列 $a$ 在索引 $i_1, i_2, \dots, i_k$ 处元素的成对异或值集合,即 $\{a_{i_x} \oplus a_{i_y} \mid 1 \le x, y \le k\}$。

例如,假设 Aidos 选择的序列为 $[1, 5, 6, 3]$。那么对于问题 ask(2),Aidos 将回答数字 $5$;对于问题 get_pairwise_xor({3, 4}),Aidos 将回答序列 $[0, 0, 5, 5]$,因为:

  • $a_3 \oplus a_4 = 6 \oplus 3 = 5$
  • $a_4 \oplus a_3 = 3 \oplus 6 = 5$
  • $a_3 \oplus a_3 = 6 \oplus 6 = 0$
  • $a_4 \oplus a_4 = 3 \oplus 3 = 0$

Temirulan 没能解开这个谜题,你的任务是帮助他。利用上述问题找出隐藏的序列。

输入格式

你的提交程序不得从标准输入读取数据,不得向标准输出打印数据,也不得与任何其他文件进行交互。

你需要实现以下函数:int[] guess(int n)

  • $n$:隐藏序列的长度。
  • 该函数在每个测试用例中仅被调用一次。
  • 该函数必须按顺序返回隐藏的序列。

你的函数可以调用以下函数:

  1. int ask(int i)

    • $i$:序列中数字的索引,$1 \le i \le n$。
    • 该函数返回隐藏序列中第 $i$ 个数字。
  2. int[] get_pairwise_xor(int[] pos)

    • $pos$:序列索引的非空列表。
    • $pos$ 中的所有元素必须是不同的整数。
    • 设 $k$ 为 $pos$ 中的元素个数。则对于每个 $1 \le i \le k$,满足 $1 \le pos_i \le n$。
    • 该函数返回一个包含 $k^2$ 个元素的排序列表:成对异或值的集合 $\{a_{pos_x} \oplus a_{pos_y} \mid 1 \le x, y \le k\}$。

对于每个测试用例,你调用这两个函数的总次数不得超过 $200$ 次。如果违反了上述任何条件,你的程序将获得 Wrong Answer 判决。否则,你的程序将获得 Accepted 判决,且你的得分将根据调用 askget_pairwise_xor 函数的总次数计算(参考“子任务”部分)。

子任务

  • $2 \le n \le 100$
  • 对于每个 $1 \le i \le n$,满足 $0 \le a_i \le 10^9$。

在本任务中,评测程序不是自适应的。这意味着序列 $a$ 在评测程序运行开始时就已经固定,且不依赖于你程序的调用。

  1. (6 分) $n \le 4$
  2. (94 分) 无额外限制。对于此子任务,你的得分计算方式如下。设 $q$ 为调用 askget_pairwise_xor 函数的总次数。
    • 如果 $q \le 15$,得分为 $94$。
    • 如果 $15 < q \le 40$,得分为 $84 - 2(q - 16)$。
    • 如果 $40 < q \le 50$,得分为 $35$。
    • 否则,得分为 $0$。

注意,每个子任务的得分是该子任务所有测试用例中得分的最小值。

说明

异或运算是按位异或(bitwise exclusive OR)。

样例

输入格式 1

4
1 5 6 3

输出格式 1

ask(2)
5
get_pairwise_xor({1, 2, 3})
{0, 0, 0, 3, 3, 4, 4, 7, 7}
ask(3)
6
get_pairwise_xor({4, 2})
{0, 0, 6, 6}
get_pairwise_xor({2})
{0}

说明

示例评测程序按以下格式读取输入: 第 1 行:$n$ 第 2 行:$a_1, a_2, \dots, a_n$

你可以在系统中下载 xoractive.zip,其中包含 Java、C++11、FPC 和 Python 2 语言的示例。

对于 Python 2,你需要实现函数 def guess(n, interactor),其中 interactor 是被测试类的实例。askget_pairwise_xor 是该类的方法。

xoractive.zip 包含每种语言的解决方案示例。

对于 Java 语言的解决方案,文件和类名必须分别命名为 Xoractive.javaXoractive

对于 Pascal 语言的解决方案,文件必须命名为 xoractive.pas

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.