第 1127 场 Codeforces Round(Div. 2,基于 2026 年墨西哥信息学奥林匹克竞赛)
D
机器人锦标赛
Robot Championship
Codeforces
未评级
原题
← CE →

机器人锦标赛AI (CI翻译)

Fran and Sofia have become huge fans of robot aura fights, so they have decided to create their own robot aura tournament. Since Sofia is a great expert on robots, Fran will need your help to win the championship.

翻译中…

A match of the tournament takes place on an $n \times n$ board. The rows are numbered from bottom to top and the columns from left to right, so $(1, 1)$ is the bottom-left corner and $(n, n)$ is the top-right corner. The opponent's robot is hidden at some unknown cell $(i, j)$ and moves once every second, but you do not see it.

翻译中…

At the beginning of each second $s$, before the robot moves, you must choose an integer $v$ with $2 \le v \le 2n$ and shoot a laser along the diagonal

翻译中…

$$\{\, (r, c) \mid r + c = v \,\}.$$ The laser touches the robot if the robot is currently on a cell of that diagonal, in which case you win immediately. Otherwise, after your shot, suppose the robot is currently at $(r, c)$, the robot moves to one of the following cells, provided the move stays inside the board:

翻译中…
  • up: $(r + 1, c)$;
  • right: $(r, c + 1)$;
  • down-left: $(r - 1, c - 1)$.
翻译中…

image The robot is at cell $(3,2)$ (its diagonal is $r+c=5$). The green laser is the diagonal $v=7$, which does not touch the robot.

翻译中…

The robot is adversarial: it may start on any cell, and it may choose any valid sequence of moves. You have to output a fixed sequence of at most $3n$ diagonals $v_1, v_2, \ldots, v_k$ such that, no matter where the robot starts and no matter how it moves, at least one of the lasers is guaranteed to touch it at some second during the tournament.

翻译中…

Input

输入格式

AI (CI翻译)

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 44$). The description of the test cases follows.

每个测试包含多个测试用例。第一行包含测试用例数量 $t$($1 \le t \le 44$)。接下来是各测试用例的描述。AI (CI翻译)

The only line of each test case contains a single integer $n$ ($2 \le n \le 100$) — the size of the board.

每个测试用例仅包含一行,其中有一个整数 $n$($2 \le n \le 100$)——棋盘的大小。AI (CI翻译)

It is guaranteed that the sum of $n^3$ over all test cases does not exceed $10^6$.

保证所有测试用例的 $n^3$ 之和不超过 $10^6$。AI (CI翻译)

Output

输出格式

AI (CI翻译)

For each testcase, print two lines. The first line contains an integer $k$ ($1 \le k \le 3n$) — the number of lasers.

对于每个测试用例,输出两行。第一行包含一个整数 $k$($1 \le k \le 3n$)——激光的数量。AI (CI翻译)

The second line contains $k$ integers $v_1, v_2, \ldots, v_k$ ($2 \le v_i \le 2n$) — the diagonals in the order they are shot.

第二行包含 $k$ 个整数 $v_1, v_2, \ldots, v_k$($2 \le v_i \le 2n$)——按发射顺序排列的对角线编号。AI (CI翻译)

You may print any valid sequence.

你可以输出任意一个合法的序列。AI (CI翻译)

Note

说明

AI (CI翻译)

For $n = 2$, the sequence $3, 3, 3$ works. The first laser $3$ removes the diagonal $r + c = 3$ (cells $(1, 2)$ and $(2, 1)$). Cell $(1, 1)$ must move onto that same diagonal on the next turn, and cell $(2, 2)$ is forced to follow the path $(2, 2) \to (1, 1) \to$ the same diagonal. The second and third lasers catch both.

当 $n = 2$ 时,序列 $3, 3, 3$ 可行。第一道激光 $3$ 会清除对角线 $r + c = 3$(格子 $(1, 2)$ 和 $(2, 1)$)。格子 $(1, 1)$ 必须在下一回合移动到同一条对角线上,而格子 $(2, 2)$ 被迫沿着路径 $(2, 2) \to (1, 1) \to$ 同一条对角线移动。第二道和第三道激光会将它们全部击中。AI (CI翻译)

For $n = 3$, the sequence $4, 4, 4$ works. A robot on the diagonal $r + c = 4$ is hit by the first laser. From the diagonal $r + c = 3$ or from cell $(3, 3)$, every move leads onto $r + c = 4$, so the second laser hits it. From cell $(1, 1)$ or from the diagonal $r + c = 5$, every move leads onto $r + c = 3$ or to cell $(3, 3)$, so the third laser hits it.

当 $n = 3$ 时,序列 $4, 4, 4$ 可行。位于对角线 $r + c = 4$ 上的机器人会被第一道激光击中。从对角线 $r + c = 3$ 或格子 $(3, 3)$ 出发时,每次移动都会到达 $r + c = 4$,因此第二道激光会将其击中。从格子 $(1, 1)$ 或对角线 $r + c = 5$ 出发时,每次移动都会到达 $r + c = 3$ 或格子 $(3, 3)$,因此第三道激光会将其击中。AI (CI翻译)

样例

Input #1
2
2
3
Output #1
3
3 3 3
3
4 4 4
InputCopy OutputCopy
题目信息

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。