Binary inversions

3.2

93 votes
Inversion Count, Sorting, Algorithms, Advanced Sorting
Problem

Construct an array of size n with an 0s and b=na 1s such that the number of inversions in the array is equal to x.

Input format

The first and only line of input contains three space-separated integers - na, and x.

Output format

Print space-separated lexicographically smallest array that satisfies the constraints. If there is no valid answer, print 1.

Constraints

1n106

1x1012

0an

Note

  • A pair (i,j) is called an inversion of A if i<j and Ai>Aj.
  • An array A is said to be lexicographically smaller than array B if there exists an index t such that Ai=Bi,i<t and At<Bt.
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

[0,1,0,1,1] have 1 inversion.

Editor Image

?