#P1706. 全排列问题

    ID: 670 远端评测题 1000ms 125MiB 尝试: 4 已通过: 3 难度: 3 上传者: 标签>搜索数学递归深度优先搜索,DFS

全排列问题

Description

Output, in lexicographic order, all non-repeating permutations of the natural numbers 11 to nn, i.e., the full set of permutations of 11 to nn. No generated sequence may contain repeated numbers.

Input Format

A single integer nn.

Output Format

All non-repeating sequences composed of 1n1 \sim n, one sequence per line. Each number should be printed in a field of width 55.

3
    1    2    3
    1    3    2
    2    1    3
    2    3    1
    3    1    2
    3    2    1

Hint

1n91 \leq n \leq 9

Translated by ChatGPT 5