#P1761. 正方形

正方形

Description

There are nn squares of different sizes. Place them one by one, each rotated by 4545 degrees, in the first quadrant. Each square must have exactly one intersection point with the xx-axis and must not overlap any previously placed squares. Subject to these conditions, the coordinate of the square’s intersection with the xx-axis should be as small as possible. After all placements, when viewed from above, which squares are at least partially visible?

Input Format

The input contains multiple test cases. For each test case, the first line contains an integer nn, and the second line contains nn positive integers representing the side lengths of the squares. The input ends with a line containing a single 00.

Output Format

For each test case, output one line containing the indices of the squares that are at least partially visible, in increasing order and separated by spaces.

4 
3 5 1 4 
3 
2 1 2 
0 
1 2 4 
1 3

Hint

Constraints

  • For 50%50\% of the testdata, n10n \le 10.
  • For 100%100\% of the testdata, n50n \le 50 and the sizes of the squares do not exceed 3030.

Translated by ChatGPT 5