8617: Wall Builder II

内存限制:256 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:Special Judge 上传者:
提交:0 通过:0

题目描述

As the builder employed by NIO, you need to build more walls for him. Now you have a number of bricks of height 111 but with different lengths. More precisely, you have nnn bricks of length 111, n−1n-1n1 bricks of length 222, ..., two bricks of length n−1n-1n1, and one brick of length nnn. The width of the bricks is negligible. You need to build a wall with these bricks whose shape must be strictly rectangular. When building the wall, you must keep the height of the bricks at 111, which means you cannot rotate them.

Of course, you can definitely build a wall with a height of 111 and a large length, but it is not a beautiful wall. In NIO's opinion, a beautiful wall should have the minimum possible circumference. Please tell him the minimum circumference of the wall, and how to build it.

输入格式

The first line contains an integer TTT (1≤T≤1001 \le T \le 1001T100), indicating the number of test cases.
Each test case contains an integer nnn (1≤n≤1001 \le n \le 1001n100) in a single line. It is guaranteed that the sum of nnn over all test cases won't exceed 200200200.

输出格式

For each test case, output an integer in a single line, indicating the minimum circumference of the wall. Then in the next n(n+1)2\dfrac{n(n+1)}{2}2n(n+1) lines, each line contains four integers x1,y1,x2,y2x_1,y_1,x_2,y_2x1,y1,x2,y2, indicating that the coordinate of the lower left of the brick is (x1,y1)(x_1,y_1)(x1,y1), and the upper right is (x2,y2)(x_2,y_2)(x2,y2).
You can consider the wall as a rectangular in the Cartesian coordinate system, where the xxx-axis represents the length and the yyy-axis represents the height. The lower left of the wall must be located at (0,0)(0,0)(0,0). If there are multiple solutions, output any.

输入样例 复制

4
1
2
3
4

输出样例 复制

4
0 0 1 1
8
0 1 1 2
1 1 2 2
0 0 2 1
14
2 1 3 2
3 1 4 2
4 1 5 2
3 0 5 1
0 1 2 2
0 0 3 1
18
4 0 5 1
2 3 3 4
3 3 4 4
4 3 5 4
3 1 5 2
3 2 5 3
0 3 2 4
0 1 3 2
0 2 3 3
0 0 4 1

数据范围与提示

A possible solution for the third test case in the sample:

分类标签