CF1250M.SmartGarden
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Berland Gardeners United Inc. hired you for the project called "SmartGarden". The main feature of this project is automatic garden watering.
Formally the garden can be represented as a square of n×n cells with rows numbered 1 to n from top to bottom and columns numbered 1 to n from left to right. Each cell of the garden contains either a plant or a slab.
It's known that slabs are located on the main diagonal of the matrix representing the garden, and in the cells that are below the main diagonal and share a side with at least one cell of the main diagonal. All the remaining cells of the garden are filled with plants.
Example of the garden for n=5 .During implementation of the project you created a smart robot that takes a list of commands as an input, which are processed one by one. Each command contains:
- a list of horizontal lines (rows in the matrix representing the garden);
- a list of vertical lines (columns in the matrix representing the garden).
While executing each command robot waters only cells in the intersection of specified rows and specified columns. So, if you specify r rows and c columns, then exactly r⋅c cells will be watered.
In the demo for the customer you have tuned robot in such a way that it waters all the garden. To do that you prepared a single command containing all n rows and all n columns.
Unfortunately, 5 hours before the demo for your customer it turned out that the CEO of Berland Gardeners United Inc. was going to take part in it. Moreover, most probably he will be standing on a garden slab during the demo!
Now you need to create a list of commands for the robot so that it waters all the plants and doesn't water any cell containing a slab. Since it's only a beta version of "SmartGarden", the total number of commands shouldn't exceed 50 .
Create a program that, for a given size of the garden, will find a list of no more than 50 commands that allow the robot to water all the plants in the garden without watering the slabs. It is allowed to water a plant several times.
输入格式
The first and the only line of the input contains a single integer n ( 2≤n≤5000 ), where n is the size of the garden.
输出格式
In the first line print the total number of commands for the robot k ( 1≤k≤50 ). In the next 2⋅k lines print all the commands. Each command should be specified by 2 lines. The first line of each command should describe rows in the command and the second line should describe columns in the command. Each of these 2 lines should have the following format:
- the first number of the line should specify the total number of items x in the appropriate list;
- then x distinct numbers follow, where each number is in the range 1…n and describes a chosen row for the first line and a chosen column for the second line.
If there are multiple ways to water the garden, print any of them.
输入输出样例
输入#1
2
输出#1
2 1 1 1 2 1 1 1 2
输入#2
4
输出#2
4 2 1 4 1 2 2 1 2 2 3 4 1 3 2 1 4 1 4 1 1