CF1103C.Johnny Solving

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Today is tuesday, that means there is a dispute in JOHNNY SOLVING team again: they try to understand who is Johnny and who is Solving. That's why guys asked Umnik to help them. Umnik gave guys a connected graph with nn vertices without loops and multiedges, such that a degree of any vertex is at least 33, and also he gave a number 1≤k≤n1 \leq k \leq n. Because Johnny is not too smart, he promised to find a simple path with length at least nk\frac{n}{k} in the graph. In reply, Solving promised to find kk simple by vertices cycles with representatives, such that:

  • Length of each cycle is at least 33.
  • Length of each cycle is not divisible by 33.
  • In each cycle must be a representative - vertex, which belongs only to this cycle among all printed cycles.

You need to help guys resolve the dispute, for that you need to find a solution for Johnny: a simple path with length at least nk\frac{n}{k} (nn is not necessarily divided by kk), or solution for Solving: kk cycles that satisfy all the conditions above. If there is no any solution - print −1-1.

今天是星期二,这意味着 JOHNNY SOLVING 团队内部又爆发了一场争论:他们试图弄清楚谁是 Johnny,谁是 Solving。因此,队员们请 Umnik 帮忙。Umnik 给了他们一个包含 nn 个顶点的连通图,该图不含自环和重边,且每个顶点的度数至少为 33;此外,他还给了一个数 1≤k≤n1 \leq k \leq n。由于 Johnny 并不聪明,他承诺在图中找出一条长度至少为 nk\frac{n}{k} 的简单路径。作为回应,Solving 承诺找出 kk 个顶点互不相交的简单环(即这些环两两之间没有公共顶点),且满足以下条件:

  • 每个环的长度至少为 33;
  • 每个环的长度不能被 33 整除;
  • 每个环中必须存在一个“代表顶点”——该顶点仅属于当前这个环,而不属于其余所有已输出的环。

你需要帮助队员们解决这场争论:即要么为 Johnny 找出一条长度至少为 nk\frac{n}{k} 的简单路径(注意:nn 不一定被 kk 整除),要么为 Solving 找出满足上述全部条件的 kk 个环。如果两种方案均不存在,则输出 −1-1。

输入格式

The first line contains three integers nn, mm and kk (1≤k≤n≤2.5⋅105,1≤m≤5⋅1051 \leq k \leq n \leq 2.5 \cdot 10^5, 1 \leq m \leq 5 \cdot 10^5)

Next mm lines describe edges of the graph in format vv, uu (1≤v,u≤n1 \leq v, u \leq n). It's guaranteed that v≠uv \neq u and all mm pairs are distinct.

It's guaranteed that a degree of each vertex is at least 33.

第一行包含三个整数 nn、mm 和 kk(1≤k≤n≤2.5⋅1051 \leq k \leq n \leq 2.5 \cdot 10^5,1≤m≤5⋅1051 \leq m \leq 5 \cdot 10^5)。

接下来的 mm 行描述图中的边,每行格式为 vv、uu(1≤v,u≤n1 \leq v, u \leq n)。保证 v≠uv \neq u,且所有 mm 个点对互不相同。

保证每个顶点的度数至少为 33。

输出格式

Print PATH in the first line, if you solve problem for Johnny. In the second line print the number of vertices in the path cc (c≥nkc \geq \frac{n}{k}). And in the third line print vertices describing the path in route order.

Print CYCLES in the first line, if you solve problem for Solving. In the following lines describe exactly kk cycles in the following format: in the first line print the size of the cycle cc (c≥3c \geq 3). In the second line print the cycle in route order. Also, the first vertex in the cycle must be a representative.

Print −1-1 if there is no any solution. The total amount of printed numbers in the output must be at most 10610^6. It's guaranteed, that if exists any solution then there is a correct output satisfies this restriction.

如果为 Johnny 解决问题,在第一行输出 PATH。
第二行输出路径中的顶点数 cc(满足 c≥nkc \geq \frac{n}{k})。
第三行按遍历顺序输出描述该路径的顶点。

如果为 Solving 解决问题,在第一行输出 CYCLES。
随后各行描述恰好 kk 个环,格式如下:每组环的第一行输出环的长度 cc(满足 c≥3c \geq 3);第二行按遍历顺序输出该环;且环中第一个顶点必须是代表元(representative)。

若不存在任何解,输出 −1-1。
输出中所有数字的总个数至多为 10610^6。题目保证:若存在解,则必存在满足该限制的正确输出。

输入输出样例

  • 输入#1

    4 6 2
    1 2
    1 3
    1 4
    2 3
    2 4
    3 4

    输出#1

    PATH
    4
    1 2 3 4
  • 输入#2

    10 18 2
    1 2
    1 3
    1 4
    1 5
    1 6
    1 7
    1 8
    1 9
    1 10
    2 3
    3 4
    2 4
    5 6
    6 7
    5 7
    8 9
    9 10
    8 10

    输出#2

    CYCLES
    4
    4 1 2 3 
    4
    7 1 5 6

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

首页