CF1713D.Tournament Countdown

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

This is an interactive problem.

There was a tournament consisting of 2n2^n contestants. The 11-st contestant competed with the 22-nd, the 33-rd competed with the 44-th, and so on. After that, the winner of the first match competed with the winner of second match, etc. The tournament ended when there was only one contestant left, who was declared the winner of the tournament. Such a tournament scheme is known as the single-elimination tournament.

You don't know the results, but you want to find the winner of the tournament. In one query, you select two integers aa and bb, which are the indices of two contestants. The jury will return 11 if aa won more matches than bb, 22 if bb won more matches than aa, or 00 if their number of wins was equal.

Find the winner in no more than ⌈13⋅2n+1⌉\left \lceil \frac{1}{3} \cdot 2^{n + 1} \right \rceil queries. Here ⌈x⌉\lceil x \rceil denotes the value of xx rounded up to the nearest integer.

Note that the tournament is long over, meaning that the results are fixed and do not depend on your queries.

这是一个交互式问题。

曾经举办过一场有 2n2^n 名参赛者的比赛。第 11 名参赛者与第 22 名参赛者对决,第 33 名参赛者与第 44 名参赛者对决,以此类推。之后,第一场对决的胜者与第二场对决的胜者再进行对决,依此类推。当场上仅剩一名参赛者时,比赛结束,该参赛者即被宣布为整场比赛的冠军。这种赛制被称为单败淘汰制。

你并不知道比赛结果,但你想找出最终的冠军。在一次查询中,你选择两个整数 aa 和 bb,分别代表两名参赛者的编号。评测系统将返回:若 aa 获胜的场数多于 bb,则返回 11;若 bb 获胜的场数多于 aa,则返回 22;若二者获胜场数相等,则返回 00。

请在不超过 ⌈13⋅2n+1⌉\left \lceil \frac{1}{3} \cdot 2^{n + 1} \right \rceil 次查询内找出冠军。其中 ⌈x⌉\lceil x \rceil 表示将 xx 向上取整后的整数值。

注意:这场比赛早已结束,因此所有比赛结果是固定的,不随你的查询而改变。

输入格式

The first line contains a single integer tt (1≤t≤2141 \leq t \leq 2^{14}) — the number of test cases.

The only line of input contains a single integer nn (1≤n≤171 \leq n \leq 17).

It is guaranteed that the sum of 2n2^n over all test cases does not exceed 2172^{17}.

第一行包含一个整数 tt(1≤t≤2141 \leq t \leq 2^{14})—— 表示测试用例的数量。

输入的唯一一行包含一个整数 nn(1≤n≤171 \leq n \leq 17)。

保证所有测试用例中 2n2^n 的总和不超过 2172^{17}。

输入输出样例

  • 输入#1

    1
    3
    
    2
    
    0
    
    2

    输出#1

    ? 1 4
    
    ? 1 6
    
    ? 5 7
    
    ! 7

说明/提示

The tournament in the first test case is shown below. The number of wins is [1,0,0,2,0,1,3,0][1,0,0,2,0,1,3,0].

In this example, the winner is the 77-th contestant.

第一个测试用例中的锦标赛如下图所示。各参赛者的获胜次数为 [1,0,0,2,0,1,3,0][1,0,0,2,0,1,3,0]。

本例中,冠军是第 77 号参赛者。

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

首页