CF1854D.Michael and Hotel
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Michael and Brian are stuck in a hotel with n rooms, numbered from 1 to n, 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 i has a teleporter that will take you to room ai (it might be that ai=i). But they don't know the values of a1,a2,…,an.
Instead, they can call up the front desk to ask queries. In one query, they give a room u, a positive integer k, and a set of rooms S. The hotel concierge answers whether a person starting in room u, and using the teleporters k times, ends up in a room in S.
Brian is in room 1. Michael wants to know the set A 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 2000 queries.
The values a1,a2,…,an are fixed before the start of the interaction and do not depend on your queries. In other words, the interactor is not adaptive.
迈克尔和布莱恩被困在一家拥有 n 个房间的酒店中,房间编号为 1 到 n,他们需要找到彼此。但这家酒店的所有房门均被锁住,唯一通行方式是使用每个房间中的传送器。房间 i 中有一个传送器,可将人传送到房间 ai(可能有 ai=i)。但他们并不知道 a1,a2,…,an 的具体取值。
相反,他们可以致电前台发起查询。每次查询中,他们提供一个房间 u、一个正整数 k 和一个房间集合 S。酒店礼宾员会回答:若某人从房间 u 出发,连续使用传送器 k 次,最终是否落在集合 S 中的某个房间内。
布莱恩位于房间 1。迈克尔希望确定房间集合 A,使得若他从 A 中的任意一个房间出发,便可通过若干次使用传送器与布莱恩相遇。他最多可进行 2000 次查询。
数值 a1,a2,…,an 在交互开始前即已固定,且不依赖于你的查询。换言之,交互器是非自适应的。
输入格式
The input contains a single integer n (2≤n≤500).
输入包含一个整数 n(2≤n≤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=5 rooms and the (hidden) array describing the behavior of the teleporters is [1,2,1,3,2].
- The first query asks whether starting from room number a=3, and using the teleporters 5 times, one ends up in one of the two rooms S=2,3. This action results in ending up in the room 1, so the answer is 0.
- The second query asks whether starting from room number a=2, and using the teleporters 5 times, one ends up in one of the two rooms S=2,3. This action results in ending up in the room 2, so the answer is 1.
在样例测试中,共有 n=5 个房间,描述传送器行为的(隐藏)数组为 [1,2,1,3,2]。
- 第一个查询询问:从房间编号 a=3 出发,使用传送器 5 次后,是否最终停留在集合 S=2,3 中的某个房间。该操作最终停留在房间 1,因此答案为 0。
- 第二个查询询问:从房间编号 a=2 出发,使用传送器 5 次后,是否最终停留在集合 S=2,3 中的某个房间。该操作最终停留在房间 2,因此答案为 1。
输入解题思路,AI测评打分。不知道怎么写?