6962.Inverse Inversions

Time Limit: 1s Memory Limit: 512MB

Your task is to create a permutation of numbers $1,2,\dots,n$ that has exactly $k$ inversions.

An inversion is a pair $(a,b)$ where $a<b$ and $p_a>p_b$ where $p_i$ denotes the number at position $i$ in the permutation.

Input Format(From the terminal/stdin)

The only input line has two integers $n$ and $k$ .

  • $1 \le n \le 10^6$
  • $0 \le k \le \frac{n(n-1)}{2}$

Output Format(To the terminal/stdout)

Print a line that contains the permutation. You can print any valid solution.

Sample Input

Copy
5 4
 · \n

Sample Output special judge

Copy
1 5 2 4 3
 · · · · \n
Source: CSES, Construction Problems, 2214

Submit

请先 登录

© 2025 FAQs