CF1368C.Even Picture
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Leo Jr. draws pictures in his notebook with checkered sheets (that is, each sheet has a regular square grid printed on it). We can assume that the sheets are infinitely large in any direction.
To draw a picture, Leo Jr. colors some of the cells on a sheet gray. He considers the resulting picture beautiful if the following conditions are satisfied:
- The picture is connected, that is, it is possible to get from any gray cell to any other by following a chain of gray cells, with each pair of adjacent cells in the path being neighbours (that is, sharing a side).
- Each gray cell has an even number of gray neighbours.
- There are exactly n gray cells with all gray neighbours. The number of other gray cells can be arbitrary (but reasonable, so that they can all be listed).
Leo Jr. is now struggling to draw a beautiful picture with a particular choice of n. Help him, and provide any example of a beautiful picture.
To output cell coordinates in your answer, assume that the sheet is provided with a Cartesian coordinate system such that one of the cells is chosen to be the origin (0,0), axes 0x and 0y are orthogonal and parallel to grid lines, and a unit step along any axis in any direction takes you to a neighbouring cell.
Leo Jr. 在他的笔记本上用带有方格纸(即每张纸上都印有规则的正方形网格)作画。我们可以假设这些纸在任意方向上都是无限延伸的。
为了绘制一幅画,Leo Jr. 将纸上的某些方格涂成灰色。他将满足以下条件的图形称为“优美的”:
- 图形是连通的,即:对于任意两个灰色方格,都存在一条由灰色方格构成的路径,使得路径中相邻的两个方格彼此共享一条边(即为上下左右四邻格);
- 每个灰色方格均有偶数个灰色邻居(邻居定义同上,即上下左右四邻格中为灰色的格子数);
- 恰好有 n 个灰色方格,其所有邻居(共最多 4 个)均为灰色;其余灰色方格的数量可以是任意的(但应为合理有限值,以便全部列出)。
目前 Leo Jr. 正在尝试为某个给定的 n 构造一幅优美的图形。请你帮助他,并给出任意一个优美的图形示例。
在答案中输出方格坐标时,请假定纸张配备了笛卡尔坐标系:其中一个方格被选定为原点 (0,0),坐标轴 0x 和 0y 相互垂直且分别平行于网格线;沿任一坐标轴向任一方向移动一个单位,即到达一个相邻方格。
输入格式
The only line contains a single integer n (1≤n≤500) — the number of gray cells with all gray neighbours in a beautiful picture.
唯一一行包含一个整数 n(1≤n≤500)—— 表示一幅“优美图片”中所有邻居均为灰色的灰色格子的数量。
输出格式
In the first line, print a single integer k — the number of gray cells in your picture. For technical reasons, k should not exceed 5⋅105.
Each of the following k lines should contain two integers — coordinates of a gray cell in your picture. All listed cells should be distinct, and the picture should satisdfy all the properties listed above. All coordinates should not exceed 109 by absolute value.
One can show that there exists an answer satisfying all requirements with a small enough k.
第一行输出一个整数 k —— 你所绘制图形中灰色格子的数量。出于技术原因,k 不得超过 5⋅105。
接下来的 k 行中,每行应包含两个整数 —— 图形中一个灰色格子的坐标。所有列出的格子必须互不相同,且该图形须满足上述全部性质。所有坐标的绝对值不得超过 109。
可以证明:存在一个满足所有要求的答案,且对应的 k 足够小。
输入输出样例
输入#1
4
输出#1
12 1 0 2 0 0 1 1 1 2 1 3 1 0 2 1 2 2 2 3 2 1 3 2 3
说明/提示
The answer for the sample is pictured below:

样例的解答如下图所示:

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