/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 40ms 17.922 MiB
#2 Accepted 52ms 19.16 MiB

Code

import sys
from itertools import *
from bisect import *
from collections import *
from math import gcd
import heapq

input = lambda: sys.stdin.readline().rstrip("\r\n")
rint = lambda: int(input())
rlist = lambda: list(map(int, input().split()))
rgrid = lambda n: [rlist() for _ in range(n)]

fmin = lambda x, y: x if x < y else y
fmax = lambda x, y: x if x > y else y
# MOD = 998244353
MOD = 10**9 + 7
INF = float("inf")


def solve():
    N = rint()
    if N % 2 == 0:
        A = list(range(1, N + 1))
        for i in range(0, N, 2):
            A[i], A[i + 1] = A[i + 1], A[i]
        return A
    A = list(range(1, N + 1))
    for i in range(0, N - 3, 2):
        A[i], A[i + 1] = A[i + 1], A[i]
    x, y, z = A[-3:]
    A[-3:] = y, z, x
    return A


TT = 1
TT = rint()
for tc in range(TT):
    ans = solve()

    # print(ans)
    print(*ans)
    # print("Yes" if ans else "No")

Information

Submit By
Type
Submission
Problem
P1210 A. Smallest Permutation
Contest
Educational Round 1
Language
PyPy 3 (Python 3.9.18 PyPy 7.3.15)
Submit At
2025-07-14 15:33:33
Judged At
2025-07-14 15:33:33
Judged By
Score
100
Total Time
52ms
Peak Memory
19.16 MiB