CF103B.Cthulhu
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super weapon. Due to high seismic activity and poor weather conditions the satellites haven't yet been able to make clear shots of the monster. The analysis of the first shot resulted in an undirected graph with n vertices and m edges. Now the world's best minds are about to determine whether this graph can be regarded as Cthulhu or not.
To add simplicity, let's suppose that Cthulhu looks from the space like some spherical body with tentacles attached to it. Formally, we shall regard as Cthulhu such an undirected graph that can be represented as a set of three or more rooted trees, whose roots are connected by a simple cycle.
It is guaranteed that the graph contains no multiple edges and self-loops.

很久以前,有一个人来到海边。那时海面风暴肆虐、漆黑一片。这个人开始呼唤小美人鱼现身,但可惜的是,他唤醒的却是克苏鲁……
而在世界的另一端,五角大楼正积极搜集信息,试图预测这只怪物的行为,并秘密研制超级武器。由于强烈的地震活动和恶劣的天气条件,卫星至今未能拍摄到怪物的清晰图像。对首张图像的分析结果得到了一个包含 n 个顶点和 m 条边的无向图。如今,全世界最杰出的头脑正着手判断:该图是否可被视为克苏鲁?
为简化问题,我们假设克苏鲁从太空看去,形似一个球状本体,其上附着若干触手。形式化地说,我们将一个无向图视为克苏鲁,当且仅当它可表示为三棵或更多棵有根树的集合,且这些树的根节点由一个简单环相连。
题目保证该图中不含重边和自环。

输入格式
The first line contains two integers — the number of vertices n and the number of edges m of the graph (1 ≤ n ≤ 100, 0 ≤ m ≤
).
Each of the following m lines contains a pair of integers x and y, that show that an edge exists between vertices x and y (1 ≤ x, y ≤ n, x ≠ y). For each pair of vertices there will be at most one edge between them, no edge connects a vertex to itself.
第一行包含两个整数——图的顶点数 n 和边数 m(1 ≤ n ≤ 100,0 ≤ m ≤ )。
接下来的 m 行中,每行包含一对整数 x 和 y,表示顶点 x 与顶点 y 之间存在一条边(1 ≤ x, y ≤ n,且 x = y)。任意一对顶点之间至多有一条边,且不存在连接顶点到其自身的边。
输出格式
Print "NO", if the graph is not Cthulhu and "FHTAGN!" if it is.
如果图不是克苏鲁图,输出 “NO”;如果是,输出 “FHTAGN!”
输入输出样例
输入#1
6 6 6 3 6 4 5 1 2 5 1 4 5 4
输出#1
FHTAGN!
输入#2
6 5 5 6 4 6 3 1 5 1 1 2
输出#2
NO
说明/提示
Let us denote as a simple cycle a set of v vertices that can be numbered so that the edges will only exist between vertices number 1 and 2, 2 and 3, ..., v - 1 and v, v and 1.
A tree is a connected undirected graph consisting of n vertices and n - 1 edges (n > 0).
A rooted tree is a tree where one vertex is selected to be the root.
我们称一个简单环为一组 v 个顶点,这些顶点可以被编号,使得边仅存在于编号为 1 与 2、2 与 3、……、v−1 与 v、v 与 1 的顶点之间。
一棵树是一个连通的无向图,包含 n 个顶点和 n−1 条边(其中 n>0)。
一棵有根树是一棵选定其中一个顶点作为根的树。
输入解题思路,AI测评打分。不知道怎么写?