CF819E.Mister B and Flight to the Moon
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In order to fly to the Moon Mister B just needs to solve the following problem.
There is a complete indirected graph with n vertices. You need to cover it with several simple cycles of length 3 and 4 so that each edge is in exactly 2 cycles.
We are sure that Mister B will solve the problem soon and will fly to the Moon. Will you?
为了飞往月球,B先生只需解决以下问题。
给定一个包含 n 个顶点的完全无向图。你需要用若干个长度为 3 和 4 的简单环来覆盖该图,使得每条边恰好属于 2 个环。
我们确信 B 先生很快就能解决这个问题,并飞向月球。你呢?
输入格式
The only line contains single integer n (3 ≤ n ≤ 300).
唯一的一行包含一个整数 n(3 ≤ n ≤ 300)。
输出格式
If there is no answer, print -1.
Otherwise, in the first line print k (1 ≤ k ≤ _n_2) — the number of cycles in your solution.
In each of the next k lines print description of one cycle in the following format: first print integer m (3 ≤ m ≤ 4) — the length of the cycle, then print m integers _v_1, _v_2, ..., v__m (1 ≤ v__i ≤ n) — the vertices in the cycle in the traverse order. Each edge should be in exactly two cycles.
如果无解,请输出 -1。
否则,第一行输出 k(1 ≤ k ≤ n²)—— 即你所给出的解中环的数量。
接下来的 k 行中,每行描述一个环,格式如下:首先输出整数 m(3 ≤ m ≤ 4)—— 表示该环的长度,然后输出 m 个整数 v₁, v₂, ..., vₘ(1 ≤ vᵢ ≤ n)—— 表示按遍历顺序排列的环上的顶点。每条边必须恰好出现在两个环中。
输入输出样例
输入#1
3
输出#1
2 3 1 2 3 3 1 2 3
输入#2
5
输出#2
6 3 5 4 2 3 3 1 5 4 4 5 2 3 4 4 3 2 1 3 4 2 1 3 3 1 5
输入解题思路,AI测评打分。不知道怎么写?