304299: CF819E. Mister B and Flight to the Moon

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Mister B and Flight to the Moon

题意翻译

## **题目描述** 为了飞往月球, B 先生需要解决以下问题。 有一个含有 $n$ 个节点的无向完全图。您需要用几个含三条或四条边的环来覆盖它,使每条边正好被两个循环覆盖。 为了更快前往月球, B 先生向你求助。 ## **输入输出格式** ### **输入格式** 一行包括一个整数 $n$ ($3<=n<=300$)。 ### **输出格式** 如果无解,请输出 $-1$ 。 否则,在第一行输出你的解法中环的个数 $k$ ($1<=k<=n^2$)。在接下来 $k$ 行中,每行描述一个环:先输出环包含的边数 $m$ ( $m = 3$ 或 $m = 4$),然后依次输出该环的顶点 $v1$ 、 $v2$ 、... 、 $vm$ ($1<=vi<=n$)。每条边应正好在两个环中

题目描述

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?

输入输出格式

输入格式


The only line contains single integer $ 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

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

Input

题意翻译

## **题目描述** 为了飞往月球, B 先生需要解决以下问题。 有一个含有 $n$ 个节点的无向完全图。您需要用几个含三条或四条边的环来覆盖它,使每条边正好被两个循环覆盖。 为了更快前往月球, B 先生向你求助。 ## **输入输出格式** ### **输入格式** 一行包括一个整数 $n$ ($3<=n<=300$)。 ### **输出格式** 如果无解,请输出 $-1$ 。 否则,在第一行输出你的解法中环的个数 $k$ ($1<=k<=n^2$)。在接下来 $k$ 行中,每行描述一个环:先输出环包含的边数 $m$ ( $m = 3$ 或 $m = 4$),然后依次输出该环的顶点 $v1$ 、 $v2$ 、... 、 $vm$ ($1<=vi<=n$)。每条边应正好在两个环中

加入题单

算法标签: