CF1644B.Anti-Fibonacci Permutation

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Let's call a permutation pp of length nn anti-Fibonacci if the condition pi−2+pi−1≠pip_{i-2} + p_{i-1} \ne p_i holds for all ii (3≤i≤n3 \le i \le n). Recall that the permutation is the array of length nn which contains each integer from 11 to nn exactly once.

Your task is for a given number nn print nn distinct anti-Fibonacci permutations of length nn.

我们称一个长度为 nn 的排列 pp 是“反斐波那契”的,如果对所有 ii(3≤i≤n3 \le i \le n)均满足条件 pi−2+pi−1≠pip_{i-2} + p_{i-1} \ne p_i。注意:排列是指一个长度为 nn 的数组,其中恰好包含从 11 到 nn 的每个整数各一次。

你的任务是:对于给定的正整数 nn,输出 nn 个互不相同的、长度为 nn 的反斐波那契排列。

输入格式

The first line contains a single integer tt (1≤t≤481 \le t \le 48) — the number of test cases.

The single line of each test case contains a single integer nn (3≤n≤503 \le n \le 50).

第一行包含一个整数 tt(1≤t≤481 \le t \le 48)—— 测试用例的数量。

每个测试用例的唯一一行包含一个整数 nn(3≤n≤503 \le n \le 50)。

输出格式

For each test case, print nn lines. Each line should contain an anti-Fibonacci permutation of length nn. In each test case, you cannot print any permutation more than once.

If there are multiple answers, print any of them. It can be shown that it is always possible to find nn different anti-Fibonacci permutations of size nn under the constraints of the problem.

对于每个测试用例,输出 nn 行。每行应包含一个长度为 nn 的反斐波那契排列。在每个测试用例中,不允许重复输出任何排列。

若存在多种答案,输出任意一种即可。可以证明:在本题约束条件下,总能找到 nn 个互不相同的大小为 nn 的反斐波那契排列。

输入输出样例

  • 输入#1

    2
    4
    3

    输出#1

    4 1 3 2
    1 2 4 3
    3 4 1 2
    2 4 1 3
    3 2 1
    1 3 2
    3 1 2

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

首页