CF1846F.Rudolph and Mimic

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

This is an interactive task.

Rudolph is a scientist who studies alien life forms. There is a room in front of Rudolph with nn different objects scattered around. Among the objects there is exactly one amazing creature — a mimic that can turn into any object. He has already disguised himself in this room and Rudolph needs to find him by experiment.

The experiment takes place in several stages. At each stage, the following happens:

  • Rudolf looks at all the objects in the room and writes down their types. The type of each object is indicated by a number; there can be several objects of the same type.
  • After inspecting, Rudolph can point to an object that he thinks is a mimic. After that, the experiment ends. Rudolph only has one try, so if he is unsure of the mimic's position, he does the next step instead.
  • Rudolf can remove any number of objects from the room (possibly zero). Then Rudolf leaves the room and at this time all objects, including the mimic, are mixed with each other, their order is changed, and the mimic can transform into any other object (even one that is not in the room).
  • After this, Rudolf returns to the room and repeats the stage. The mimic may not change appearance, but it can not remain a same object for more than two stages in a row.

Rudolf's task is to detect mimic in no more than five stages.

这是一个交互式任务。

鲁道夫是一位研究外星生命形式的科学家。在鲁道夫面前有一间屋子,其中散落着 nn 个不同的物体。这些物体中恰好有一个神奇的生物——“拟态者”(mimic),它能变成任意一种物体。该拟态者已在此房间中完成伪装,鲁道夫需通过实验将其找出。

实验分若干阶段进行。在每一阶段中,发生以下事件:

  • 鲁道夫观察房间内所有物体,并记录下它们的类型。每个物体的类型用一个数字表示;可能存在多个类型相同的物体。
  • 观察完毕后,鲁道夫可以指出他认定为拟态者的那个物体。此后实验立即结束。鲁道夫仅有一次猜测机会;因此,若他对拟态者的位置尚无把握,则转而执行下一步。
  • 鲁道夫可从房间中移除任意数量的物体(包括不移除任何物体)。随后鲁道夫离开房间;此时,所有剩余物体(包括拟态者)将被彻底混洗,其相对顺序被打乱,且拟态者可转变为任意其他物体(甚至可变为当前房间中并不存在的类型)。
  • 此后,鲁道夫返回房间,并重复本阶段。拟态者在单次变换后可保持外观不变,但不能连续三个阶段都保持同一外观(即:它最多只能连续两个阶段维持相同外观)。

鲁道夫的任务是在至多五个阶段内识别出拟态者。

输入格式

The first line contains one integer tt (1≤t≤1000)(1 \le t \le 1000) — the number of test cases.

The first line of each test case contains one integer nn (2≤n≤200)(2 \le n \le 200) — the number of objects in the room.

The second line of each test case contains nn integers a1a_1,a2a_2,...,ana_n (1≤ai≤9)(1 \le a_i \le 9) — object types.

第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000)—— 测试用例的数量。

每个测试用例的第一行包含一个整数 nn(2≤n≤2002 \le n \le 200)—— 房间中物体的数量。

每个测试用例的第二行包含 nn 个整数 a1a_1、a2a_2、…、ana_n(1≤ai≤91 \le a_i \le 9)—— 物体的类型。

输入输出样例

  • 输入#1

    3
    5
    1 1 2 2 3
    
    2 1 1 2
    
    2 2 2
    
    2
    
    8
    1 2 3 4 3 4 2 1
    
    4 3 4 3 2 2 1 3
     
    2 3 3 2
    
    5 3 2
    
    2 5
    
    15
    1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 
    
    1 2 3 4 5 6 7 8 7 9 5 4 3 2 1

    输出#1

    - 1 5
    
    - 1 3
    
    - 2 1 2
    
    ! 1
    
    
    - 0
    
    - 4 1 3 7 8
    
    - 1 4
    
    - 1 2
    
    ! 2
    
    
    - 0
    
    ! 10

说明/提示

Explanation for the first test: initial array is x1x_1, x2x_2, x3x_3, x4x_4, x5x_5. Mimic is in first position.

  • Delete the fifth object. After that, the positions are shuffled, and the mimic chose not to change his appearance. Object positions become x4x_4, x1x_1, x2x_2, x3x_3.
  • Delete the third objects. The mimic is forced to turn into another object, because it has already been in the form 11 for two stages. The mimic chose to transform into 22, the objects are shuffled and become x3x_3, x4x_4, x1x_1.
  • Delete the first and second objects. The objects positions become x1x_1. Only the mimic remains, and it remains an object 22.
  • Point to the first element.

第一个测试用例的解释:初始数组为 x1x_1, x2x_2, x3x_3, x4x_4, x5x_5,模仿者位于第一个位置。

  • 删除第五个对象。之后,剩余对象的位置被随机重排,且模仿者选择不改变自身外观。对象位置变为 x4x_4, x1x_1, x2x_2, x3x_3。
  • 删除第三个对象。模仿者被迫转变为另一对象,因为它已连续两轮保持形态 11。模仿者选择变为形态 22,随后对象被随机重排,位置变为 x3x_3, x4x_4, x1x_1。
  • 删除第一个和第二个对象。对象位置变为 x1x_1。此时仅剩模仿者,且它保持为对象 22。
  • 指向第一个元素。

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

首页