QOJ.ac

QOJ

Limite de temps : 6 s Limite de mémoire : 2048 MB Points totaux : 100 Interactif
Statistiques

你正在研究计算机科学的最新突破:动画字体。突然间,你同事的代码看起来非常惊艳,你终于有动力去审查它了。不幸的是,由于不断的旋转,很难区分 $+$(加号)和 $\times$(乘号)运算符(所有其他字符仍然清晰可辨)。

你正在审查的函数接收 $n+1$ 个整数 $a_0, a_1, \dots, a_n$ 作为输入,并返回以下值:

$$(\dots((a_0 \operatorname{op}_1 a_1) \operatorname{op}_2 a_2) \operatorname{op}_3 a_3) \dots \operatorname{op}_n a_n) \pmod{10^9 + 7}$$

其中 $n$ 个运算符 $\operatorname{op}_1, \operatorname{op}_2, \dots, \operatorname{op}_n$ 要么是 $+$,要么是 $\times$。例如,当给定输入 $(a_0, a_1, a_2) = (1, 1, 2)$ 且隐藏运算符为 $(\operatorname{op}_1, \operatorname{op}_2) = (+, \times)$ 时,该函数返回 $((1 + 1) \times 2) = 4 \pmod{10^9 + 7}$。

你仍然可以对某些输入执行该函数几次并读取返回的值。利用这一点来恢复这些运算符。

交互

这是一个交互式问题。你的提交将针对一个交互器运行,该交互器读取你的提交的标准输出,并向你的提交的标准输入写入内容。此交互需要遵循特定的协议:

交互器首先发送一行,包含一个整数 $n$ ($1 \le n \le 4000$),即隐藏运算符的数量。

然后,你的程序应进行最多 275 次查询以确定运算符。每次查询通过打印一行格式为 “? $a_0$ $a_1$ $\dots$ $a_n$” ($0 \le a_i < 10^9 + 7$) 的内容来完成。交互器将通过打印一行包含一个整数的内容来响应,该整数为以下表达式的值:

$$(\dots((a_0 \operatorname{op}_1 a_1) \operatorname{op}_2 a_2) \operatorname{op}_3 a_3) \dots \operatorname{op}_n a_n) \pmod{10^9 + 7}$$

确保在每次写入后刷新缓冲区。

当你确定了运算符后,打印一行格式为 “! $s$” 的内容,其中 $s$ 是一个由恰好 $n$ 个字符组成的字符串,这些字符全为 “+” 或 “x” (乘号)。该字符串的第 $i$ 个字符应为 $\operatorname{op}_i$。此行不计入你的查询次数。

使用超过 275 次查询将导致错误答案判决。

提供了一个测试工具来帮助你开发解决方案。

样例

输入格式 1

2
? 1 1 2
4
? 1 1 3
6
! +x

输出格式 1

(交互器输出)

输入格式 2

10
? 1 1 1 1 1 1 1 1 1 1 1
5
? 0 4 2 4 2 4 2 4 2 4 2
6224
? 1 2 3 4 5 6 7 8 9 10 11
640750
! ++xxx+x+xx

输出格式 2

(交互器输出)

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.