#P14033. 【MX-X20-T7】「FAOI-R7」子集乘积(subset)

    ID: 13981 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>动态规划 DP数学贪心交互题Special JudgeO2优化分治最短路鸽笼原理其它技巧构造梦熊比赛

【MX-X20-T7】「FAOI-R7」子集乘积(subset)

Description

This is an interactive problem.

There is a 01-string aa of length nn. This 01-string is predetermined before you start querying. You can query the interactor at most mm times, and then determine the value of each digit in the aa sequence.

You have two types of queries, both of which count toward the number of operations. The formats are as follows:

  • ? s: Here ss is a string of length nn consisting only of the digits 0 and 1. Then, let t1=i=1n[si=1][ai=0]t_1 = \sum_{i=1}^{n} [s_i = 1][a_i = 0] and t2=i=1n[si=1][ai=1]t_2 = \sum_{i=1}^{n} [s_i = 1][a_i = 1]. The interactor will output the value t1×t2t_1 \times t_2.

  • ! s: This indicates that you have determined the value of each digit in the aa sequence. You need to represent the aa sequence as a 01-string ss.

    • If for all i[1,n]i \in [1,n], si=ais_i = a_i, the interactor will output 11. If this is the last test case, the judge will give an Accepted result; if it is not the last test case, you need to proceed to the next test case.
    • Otherwise, the interactor will output 00.
    • Specifically, this operation can be used at most 2\boldsymbol{2} times. If you use it more than 2\boldsymbol{2} times, the judge will give a Wrong Answer result.

Input Format

This problem contains multiple test cases per test point.

The first line contains a non-negative integer TT, the number of test cases.

For each test case, the first line inputs a positive integer nn. Then, the interaction proceeds as described in the problem description.

You can use the following statements to flush the buffer:

  • For C/C++: fflush(stdout);
  • For C++: std::cout << std::flush;
  • For Java: System.out.flush();
  • For Python: stdout.flush();
  • For Pascal: flush(output);
  • For other languages, please refer to the help documentation of the respective language.

Specifically, for C++, if you use std::endl instead of '\n' when outputting a newline, it will automatically flush the buffer.

Output Format

See the input format.

3
1

1
2

1

0

1
8

0

1


! 0


? 11

! 00

! 01


? 10100001

! 10100001

Hint

Explanation

The sample is only for demonstrating the interaction format and does not guarantee the rationality of the sample output strategy.

This sample has 33 test cases.

For the first test case, n=1n = 1. We guess the final string as 0 and get it right on the first try.

For the second test case, n=2n = 2. We first query the product of the counts of 0s and 1s at positions 11 and 22 and get 11. We first guess the final string as 00 and find it is wrong. Then we guess the final string as 01 and find it is correct.

For the third test case, n=8n = 8. We first query the product of the counts of 0s and 1s at positions 11, 33, and 88 and get 00. We first guess the final string as 10100001 and find it is correct.

Scoring Criteria

Let xx be the maximum number of queries you use across all test cases in all test points. Then:

  • If x>1001x > 1001, you will get 00 points.
  • If x=1001x = 1001, you will get 55 points.
  • If 385x1000385 \le x \le 1000, you will get $5 + 90 \times \biggl(1 - \displaystyle\frac{x-385}{1001-385}\biggr)$ points.
  • If x384x \le 384, you will get 100100 points.

Data Range

This problem uses bundled testing.

For all data, it is guaranteed that 1T101 \le T \le 10, 1n10001 \le n \le 1000.


Translated by DeepSeek V3.1