CF1854D.Michael and Hotel

NOI/NOI+/CTSC

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Michael and Brian are stuck in a hotel with nn rooms, numbered from 11 to nn, and need to find each other. But this hotel's doors are all locked and the only way of getting around is by using the teleporters in each room. Room ii has a teleporter that will take you to room aia_i (it might be that ai=ia_i = i). But they don't know the values of a1,a2,…,ana_1,a_2, \dots, a_n.

Instead, they can call up the front desk to ask queries. In one query, they give a room uu, a positive integer kk, and a set of rooms SS. The hotel concierge answers whether a person starting in room uu, and using the teleporters kk times, ends up in a room in SS.

Brian is in room 11. Michael wants to know the set AA of rooms so that if he starts in one of those rooms they can use the teleporters to meet up. He can ask at most 20002000 queries.

The values a1,a2,…,ana_1, a_2, \dots, a_n are fixed before the start of the interaction and do not depend on your queries. In other words, the interactor is not adaptive.

迈克尔和布莱恩被困在一家拥有 nn 个房间的酒店中,房间编号为 11 到 nn,他们需要找到彼此。但这家酒店的所有房门均被锁住,唯一通行方式是使用每个房间中的传送器。房间 ii 中有一个传送器,可将人传送到房间 aia_i(可能有 ai=ia_i = i)。但他们并不知道 a1,a2,…,ana_1, a_2, \dots, a_n 的具体取值。

相反,他们可以致电前台发起查询。每次查询中,他们提供一个房间 uu、一个正整数 kk 和一个房间集合 SS。酒店礼宾员会回答:若某人从房间 uu 出发,连续使用传送器 kk 次,最终是否落在集合 SS 中的某个房间内。

布莱恩位于房间 11。迈克尔希望确定房间集合 AA,使得若他从 AA 中的任意一个房间出发,便可通过若干次使用传送器与布莱恩相遇。他最多可进行 20002000 次查询。

数值 a1,a2,…,ana_1, a_2, \dots, a_n 在交互开始前即已固定,且不依赖于你的查询。换言之,交互器是非自适应的。

输入格式

The input contains a single integer nn (2≤n≤5002 \leq n \leq 500).

输入包含一个整数 nn(2≤n≤5002 \leq n \leq 500)。

输入输出样例

  • 输入#1

    5
    
    0
    
    1

    输出#1

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

说明/提示

In the sample test, there are n=5n=5 rooms and the (hidden) array describing the behavior of the teleporters is [1,2,1,3,2][1, 2, 1, 3, 2].

  • The first query asks whether starting from room number a=3a=3, and using the teleporters 55 times, one ends up in one of the two rooms S=2,3S={2, 3}. This action results in ending up in the room 11, so the answer is 00.
  • The second query asks whether starting from room number a=2a=2, and using the teleporters 55 times, one ends up in one of the two rooms S=2,3S={2, 3}. This action results in ending up in the room 22, so the answer is 11.

在样例测试中,共有 n=5n=5 个房间,描述传送器行为的(隐藏)数组为 [1,2,1,3,2][1, 2, 1, 3, 2]。

  • 第一个查询询问:从房间编号 a=3a=3 出发,使用传送器 55 次后,是否最终停留在集合 S=2,3S={2, 3} 中的某个房间。该操作最终停留在房间 11,因此答案为 00。
  • 第二个查询询问:从房间编号 a=2a=2 出发,使用传送器 55 次后,是否最终停留在集合 S=2,3S={2, 3} 中的某个房间。该操作最终停留在房间 22,因此答案为 11。

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

首页