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 nn 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 aa and bb the driver always chooses the same path whenever he drives from aa to bb. Note that aa and bb here do not have to be the endpoints of a ride and that the path from bb to aa can be different. On the contrary, if the driver ever has driven two different paths from aa to bb, 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——而这个出口正是你精准预测的位置。你叫了一辆出租车送他回家,突然间想到了一个问题。

你的城市中有 nn 个十字路口,以及若干条连接其中某些路口的双向道路。一次出租车行程是从某个十字路口到另一个十字路口的一条路径,且不允许重复经过同一个十字路口。你手头有一组由同一位司机完成的行程记录,现在你想知道:这位司机有可能是机器人,还是必定是人类?

你认为该司机有可能是机器人,当且仅当:对任意两个十字路口 aa 和 bb,只要该司机从 aa 驾驶至 bb,他总是选择完全相同的路径。注意:此处的 aa 和 bb 不必是某次行程的实际起点和终点;此外,从 bb 到 aa 的路径可以与从 aa 到 bb 的路径不同。相反,如果该司机曾两次从 aa 到 bb 选择了不同的路径,那么他必定是人类。

给定城市的道路系统以及你所掌握的所有行程记录,请判断该司机是否有可能是机器人。

输入格式

Each test contains one or more test cases. The first line contains a single integer tt (1≤t≤3⋅1051 \le t \le 3 \cdot 10^5) — the number of test cases.

The first line of each test case contains a single integer nn (1≤n≤3⋅1051 \le n \le 3 \cdot 10^5) — the number of crossroads in the city.

The next line contains a single integer qq (1≤q≤3⋅1051 \le q \le 3 \cdot 10^5) — the number of rides available to you.

Each of the following qq lines starts with a single integer kk (2≤k≤n2 \le k \le n) — the number of crossroads visited by the driver on this ride. It is followed by kk integers c1c_1, c2c_2, ..., ckc_k (1≤ci≤n1 \le c_i \le 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 kk among all rides of all test cases does not exceed 3⋅1053 \cdot 10^5.

It is guaranteed that the sum of values nn and the sum of values qq doesn't exceed 3⋅1053 \cdot 10^5 among all test cases.

每个测试包含一个或多个测试用例。第一行包含一个整数 tt(1≤t≤3⋅1051 \le t \le 3 \cdot 10^5),表示测试用例的数量。

每个测试用例的第一行包含一个整数 nn(1≤n≤3⋅1051 \le n \le 3 \cdot 10^5),表示城市中路口的数量。

下一行包含一个整数 qq(1≤q≤3⋅1051 \le q \le 3 \cdot 10^5),表示可供你选择的乘车次数。

接下来的 qq 行,每行以一个整数 kk(2≤k≤n2 \le k \le n)开头,表示该次乘车中司机经过的路口数量;随后是 kk 个整数 c1c_1, c2c_2, ..., ckc_k(1≤ci≤n1 \le c_i \le n),表示司机按顺序经过的各路口编号。保证同一趟乘车中所有路口互不相同。

保证所有测试用例中所有乘车的 kk 值之和不超过 3⋅1053 \cdot 10^5。

保证所有测试用例中 nn 的总和与 qq 的总和均不超过 3⋅1053 \cdot 10^5。

输出格式

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 11 to crossroads 33. It must be a human.

In the second example the driver always drives the cycle 1→2→3→4→11 \to 2 \to 3 \to 4 \to 1 until he reaches destination.

在第一个例子中,显然司机使用了两种不同的方式从路口 11 到达路口 33。这必定是人类驾驶员。

在第二个例子中,司机始终沿环路 1→2→3→4→11 \to 2 \to 3 \to 4 \to 1 行驶,直至抵达目的地。

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

首页