CF1811F.Is It Flower?
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Vlad found a flowerbed with graphs in his yard and decided to take one for himself. Later he found out that in addition to the usual graphs, k-flowers also grew on that flowerbed. A graph is called a k-flower if it consists of a simple cycle of length k, through each vertex of which passes its own simple cycle of length k and these cycles do not intersect at the vertices. For example, 3-flower looks like this:

Note that 1-flower and 2-flower do not exist, since at least 3 vertices are needed to form a cycle.
Vlad really liked the structure of the k-flowers and now he wants to find out if he was lucky to take one of them from the flowerbed.
弗拉德在自家院子里发现了一片长着图的花坛,便决定从中摘取一朵。后来他发现,除了普通的图之外,花坛上还生长着 k-花。一个图被称为 k-花,当且仅当它由一个长度为 k 的简单环构成,且该环的每个顶点都恰好属于一个(自身专属的)长度为 k 的简单环,且这些专属环之间在顶点上互不相交。例如,3-花如下所示:

注意:1-花和 2-花均不存在,因为构造一个环至少需要 3 个顶点。
弗拉德非常喜欢 k-花的结构,现在他想知道:自己是否幸运地从花坛中摘到了其中一朵。
输入格式
The first line of input contains the single integer t (1≤t≤104) — the number of test cases in the test.
The descriptions of the cases follow. An empty string is written before each case.
The first line of each case contains two integers n and m (2≤n≤2⋅105, 1≤m≤min(2⋅105,2n⋅(n−1))) — the number of vertices and edges in the graph, respectively.
The next m lines contain two integers each u and v (1≤u,v≤n, u=v) — numbers of vertices connected by an edge. It is guaranteed that the graph does not contain multiple edges and self-loops.
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105. It is also guaranteed for the sum of m over all test cases.
输入的第一行包含一个整数 t(1≤t≤104)—— 表示测试用例的数量。
随后是各测试用例的描述。每个测试用例前均有一行空字符串。
每个测试用例的第一行包含两个整数 n 和 m(2≤n≤2⋅105,1≤m≤min(2⋅105,2n⋅(n−1)))—— 分别表示图中顶点与边的数量。
接下来的 m 行,每行包含两个整数 u 和 v(1≤u,v≤n,u=v)—— 表示由一条边相连的两个顶点的编号。保证图中不含重边和自环。
保证所有测试用例的 n 之和不超过 2⋅105;同样地,所有测试用例的 m 之和也满足该上限。
输出格式
Output t lines, each of which is the answer to the corresponding test case. As an answer, output "YES" if Vlad's graph is a k-flower for some k, and "NO" otherwise.
You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
输出 t 行,每行对应一个测试用例的答案。若弗拉德的图是某个 k 对应的 k-花图,则输出 "YES";否则输出 "NO"。
答案大小写不敏感(例如,字符串 "yEs"、"yes"、"Yes" 和 "YES" 均被视为肯定回答)。
输入输出样例
输入#1
5 9 12 1 2 3 1 2 3 1 6 4 1 6 4 3 8 3 5 5 8 9 7 2 9 7 2 8 12 1 2 3 1 2 3 1 6 4 1 6 4 3 8 3 5 5 8 8 7 2 8 7 2 4 3 1 2 4 2 3 1 6 8 6 3 6 4 5 3 5 2 3 2 3 1 2 1 2 4 5 7 2 4 2 5 3 4 3 5 4 1 4 5 1 5
输出#1
YES NO NO NO NO
输入#2
4 2 1 1 2 8 9 1 2 8 4 8 2 6 4 6 5 4 7 3 2 3 7 2 5 9 12 2 9 2 8 6 9 6 8 6 5 6 1 9 8 9 3 9 1 8 3 8 7 5 7 3 3 1 2 1 3 2 3
输出#2
NO NO NO NO
输入解题思路,AI测评打分。不知道怎么写?