CF1056H.Detect Robots
NOI/NOI+/CTSC
通过率:0%
时间限制:1.00s
内存限制:1024MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You successfully found poor Arkady near the exit of the station you've perfectly predicted. You sent him home on a taxi and suddenly came up with a question.
There are n crossroads in your city and several bidirectional roads connecting some of them. A taxi ride is a path from some crossroads to another one without passing the same crossroads twice. You have a collection of rides made by one driver and now you wonder if this driver can be a robot or they are definitely a human.
You think that the driver can be a robot if for every two crossroads a and b the driver always chooses the same path whenever he drives from a to b. Note that a and b here do not have to be the endpoints of a ride and that the path from b to a can be different. On the contrary, if the driver ever has driven two different paths from a to b, they are definitely a human.
Given the system of roads and the description of all rides available to you, determine if the driver can be a robot or not.
你成功地在车站出口附近找到了可怜的Arkady——而这个出口正是你精准预测的位置。你叫了一辆出租车送他回家,突然间想到了一个问题。
你的城市中有 n 个十字路口,以及若干条连接其中某些路口的双向道路。一次出租车行程是从某个十字路口到另一个十字路口的一条路径,且不允许重复经过同一个十字路口。你手头有一组由同一位司机完成的行程记录,现在你想知道:这位司机有可能是机器人,还是必定是人类?
你认为该司机有可能是机器人,当且仅当:对任意两个十字路口 a 和 b,只要该司机从 a 驾驶至 b,他总是选择完全相同的路径。注意:此处的 a 和 b 不必是某次行程的实际起点和终点;此外,从 b 到 a 的路径可以与从 a 到 b 的路径不同。相反,如果该司机曾两次从 a 到 b 选择了不同的路径,那么他必定是人类。
给定城市的道路系统以及你所掌握的所有行程记录,请判断该司机是否有可能是机器人。
输入格式
Each test contains one or more test cases. The first line contains a single integer t (1≤t≤3⋅105) — the number of test cases.
The first line of each test case contains a single integer n (1≤n≤3⋅105) — the number of crossroads in the city.
The next line contains a single integer q (1≤q≤3⋅105) — the number of rides available to you.
Each of the following q lines starts with a single integer k (2≤k≤n) — the number of crossroads visited by the driver on this ride. It is followed by k integers c1, c2, ..., ck (1≤ci≤n) — the crossroads in the order the driver visited them. It is guaranteed that all crossroads in one ride are distinct.
It is guaranteed that the sum of values k among all rides of all test cases does not exceed 3⋅105.
It is guaranteed that the sum of values n and the sum of values q doesn't exceed 3⋅105 among all test cases.
每个测试包含一个或多个测试用例。第一行包含一个整数 t(1≤t≤3⋅105),表示测试用例的数量。
每个测试用例的第一行包含一个整数 n(1≤n≤3⋅105),表示城市中路口的数量。
下一行包含一个整数 q(1≤q≤3⋅105),表示可供你选择的乘车次数。
接下来的 q 行,每行以一个整数 k(2≤k≤n)开头,表示该次乘车中司机经过的路口数量;随后是 k 个整数 c1, c2, ..., ck(1≤ci≤n),表示司机按顺序经过的各路口编号。保证同一趟乘车中所有路口互不相同。
保证所有测试用例中所有乘车的 k 值之和不超过 3⋅105。
保证所有测试用例中 n 的总和与 q 的总和均不超过 3⋅105。
输出格式
Output a single line for each test case.
If the driver can be a robot, output "Robot" in a single line. Otherwise, output "Human".
You can print each letter in any case (upper or lower).
每个测试用例输出一行。
如果该驾驶员可以是机器人,则输出一行“Robot”;否则,输出一行“Human”。
每个字母可使用任意大小写(大写或小写)。
输入输出样例
输入#1
1 5 2 4 1 2 3 5 3 1 4 3
输出#1
Human
输入#2
1 4 4 3 1 2 3 3 2 3 4 3 3 4 1 3 4 1 2
输出#2
Robot
说明/提示
In the first example it is clear that the driver used two different ways to get from crossroads 1 to crossroads 3. It must be a human.
In the second example the driver always drives the cycle 1→2→3→4→1 until he reaches destination.
在第一个例子中,显然司机使用了两种不同的方式从路口 1 到达路口 3。这必定是人类驾驶员。
在第二个例子中,司机始终沿环路 1→2→3→4→1 行驶,直至抵达目的地。
输入解题思路,AI测评打分。不知道怎么写?