Universal Cup Judging System

Universal Cup

时间限制: 1.0 s 内存限制: 1024 MB 总分: 100 难度: [显示] 交互
统计

这是一个交互式问题。

在计算机科学中,最大子数组和问题(也称为最大段和问题)是指在一个给定的一维数字数组 $A_1, A_2, \dots, A_n$ 中,寻找一个和最大的连续子数组。形式上,任务是找到索引 $i$ 和 $j$,使得以下和尽可能大:

$$\sum_{i \le k \le j} A_k$$

也可以选择一个空子数组,这意味着你找到了一个和为 0 的空数组。最大子数组和的值记为 $MSS(A)$。例如,$MSS([-2, 1, 4, -3, 5]) = 7$,$MSS([-5]) = 0$,以及 $MSS([-1, -2]) = 0$。

小青鱼(Little Cyan Fish)正在强大的库比克大学(PKU)修读库比克理论课程。今天,库比克教授(Prof. Kubic)让小青鱼在课上和他玩以下游戏:

库比克教授有一个整数序列 $a_1, a_2, \dots, a_n$。小青鱼最多可以向库比克教授询问 $2n$ 次以下形式的问题:

  • ? l r:查询 $MSS(a_l, a_{l+1}, \dots, a_r)$ 的值。

小青鱼的任务是报告一个序列 $b_1, b_2, \dots, b_n$,满足:

  • 对于所有 $1 \le l \le r \le n$,都有 $MSS(a_l, a_{l+1}, \dots, a_r) = MSS(b_l, b_{l+1}, \dots, b_r)$。

小青鱼发现这个任务非常有挑战性。你能帮他制定一个策略来完成库比克教授的任务吗?

交互

单个测试文件中包含多个测试用例。输入的第一行包含一个整数 $T$ ($1 \le T \le 10^4$),表示测试用例的数量。

对于每个测试用例,输入的第一行包含一个整数 $n$ ($1 \le n \le 2\,000$)。

然后,交互开始。在每个测试用例中,你最多可以执行 $2n$ 次查询。要执行查询,你需要打印一行 ? l r ($1 \le l \le r \le n$),表示一次查询。然后,你需要从标准输入中读取查询结果。

要给出你的答案,你需要打印 ! b_1 b_2 \dots b_n。你需要确保 $-10^{15} \le b_i \le 10^{15}$。打印答案不被视为查询,不计入 $2n$ 的限制。打印答案后,你需要读取下一个测试用例,或者立即终止程序。

打印查询后,请务必输出换行符并刷新输出。为此,在 C++ 中使用 fflush(stdout)cout.flush(),在 Java 中使用 System.out.flush(),在 Pascal 中使用 flush(output),或在 Python 中使用 stdout.flush()

保证 $-10^9 \le a_i \le 10^9$,且所有测试用例的 $n$ 之和不超过 $10^4$。

在本问题中,保证交互器是非自适应的。也就是说,$a_i$ 的值在交互过程开始前就已经确定。它们不会根据你的查询而改变。

样例

输入 1

2
3
1
0
1
5
4
5

输出 1

? 1 1
? 2 2
? 3 3
! 1 -1 1
? 1 3
? 3 5
! 2 -1 3 -4 5

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.