시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 31 | 10 | 9 | 30.000% |
You are given a directed graph of $n$ vertices numbered from $0$ to $n - 1$. You are also given two integers $p$ and $q$ such that $1 \leq p, q \leq n$.
The edges of the graph are constructed as follows: for every vertex $i$,
Obviously, the graph has exactly $(n - p) + (n - q)$ edges.
Find any Hamiltonian path in this graph, or determine that it does not exist.
Recall that a Hamiltonian path is a path that visits every vertex exactly once.
The first line of input contains an integer $T$ ($1 \leq T \leq 10^4$), the number of test cases.
Each test case consists of a single line containing three integers: $n$, $p$, and $q$ ($1 \leq p, q \leq n \leq 10^6$).
It is guaranteed that the sum of $n$ over all test cases does not exceed $10^6$.
For each test case, print a single line containing $n$ integers that represent the order of vertices in a Hamiltonian path, or print $-1$ if it does not exist.
If there are multiple solutions, print any one of them.
3 5 3 2 8 2 4 13 5 7
2 0 3 1 4 -1 0 5 10 3 8 1 6 11 4 9 2 7 12