CF1896G.Pepe Racing

NOI/NOI+/CTSC

通过率:0%

时间限制:5.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This is an interactive problem.

There are n2n^2 pepes labeled 1,2,…,n21, 2, \ldots, n^2 with pairwise distinct speeds. You would like to set up some races to find out the relative speed of these pepes.

In one race, you can choose exactly nn distinct pepes and make them race against each other. After each race, you will only know the fastest pepe of these nn pepes.

Can you order the n2−n+1n^2-n+1 fastest pepes in at most 2n2−2n+12n^2 - 2n + 1 races? Note that the slowest n−1n - 1 pepes are indistinguishable from each other.

Note that the interactor is adaptive. That is, the relative speeds of the pepes are not fixed in the beginning and may depend on your queries. But it is guaranteed that at any moment there is at least one initial configuration of pepes such that all the answers to the queries are consistent.

这是一个交互式问题。

有 n2n^2 只 pepes,编号为 1,2,…,n21, 2, \ldots, n^2,它们两两具有不同的速度。你希望安排若干场比赛,以确定这些 pepes 的相对速度顺序。

在一场比赛中,你恰好可以选择 nn 只互不相同的 pepes,让它们相互比赛。每场比赛结束后,你仅能得知这 nn 只 pepes 中速度最快的一只。

你能否在至多 2n2−2n+12n^2 - 2n + 1 场比赛中,确定出最快的 n2−n+1n^2-n+1 只 pepes 的完整速度顺序?注意:最慢的 n−1n - 1 只 pepes 彼此之间无法区分。

请注意:该交互器是自适应的。也就是说,pepes 的相对速度并非在初始时就固定,而是可能依赖于你所提出的查询。但可以保证:在任意时刻,至少存在一种 pepes 的初始速度配置,使得所有已给出的查询回答均与此配置一致。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1041 \le t \le 10^4). The description of the test cases follows.

The only line of each test case contains a single integer nn (2≤n≤202 \le n \le 20) — the number of pepes in one race.

After reading the integer nn for each test case, you should begin the interaction.

It is guaranteed that the sum of n3n^3 over all test cases does not exceed 3⋅1053 \cdot 10^5.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1041 \le t \le 10^4)。随后是各测试用例的描述。

每个测试用例仅有一行,包含一个整数 nn(2≤n≤202 \le n \le 20)—— 表示一场比赛中 pepes 的数量。

对每个测试用例读入整数 nn 后,你应开始交互。

保证所有测试用例的 n3n^3 之和不超过 3⋅1053 \cdot 10^5。

输入输出样例

  • 输入#1

    1
    2
    
    2
    
    4
    
    4
    
    3
    
    2

    输出#1

    ? 1 2
    
    ? 3 4
    
    ? 2 4
    
    ? 2 3
    
    ? 2 1
    
    ! 4 3 2

输入解题思路,AI测评打分。不知道怎么写?

首页