#P16764. [GKS 2020 #E] High Buildings

    ID: 19108 远端评测题 1000ms 1024MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>2020Special Judge构造分类讨论Google Kick Start

[GKS 2020 #E] High Buildings

Problem Description

In an unspecified country, Google has an office campus consisting of NN office buildings in a line, numbered from 11 to NN from left to right. When represented in meters, the height of each building is an integer between 11 to NN, inclusive.

Andre and Sule are two Google employees working in this campus. On their lunch break, they wanted to see the skyline of the campus they are working in. Therefore, Andre went to the leftmost point of the campus (to the left of building 11), looking towards the rightmost point of the campus (to the right of building NN). Similarly, Sule went to the rightmost point of the campus, looking towards the leftmost point of the campus.

To Andre, a building xx is visible if and only if there is no building to the left of building xx that is strictly higher than building xx. Similarly, to Sule, a building xx is visible if and only if there is no building to the right of building xx that is strictly higher than building xx.

Andre learned that there are AA buildings that are visible to him, while Sule learned that there are BB buildings that are visible to him. After they regrouped and exchanged information, they also learned that there are CC buildings that are visible to both of them.

They are wondering about the height of each building. They are giving you the value of NN, AA, BB, and CC for your information. As their friend, you would like to construct a possible height for each building such that the information learned on the previous paragraph is correct, or indicate that there is no possible height construction that matches the information learned (thus at least one of them must have been mistaken).

Input Format

The first line of the input gives the number of test cases, TT. TT test cases follow. Each consists of a single line with four integers NN, AA, BB, and CC: the information given by Andre and Sule.

Output Format

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 11) and yy is IMPOSSIBLE if there is no possible height for each building according to the above information, or NN space-separated integers otherwise. The ii-th integer in yy must be the height of the ii-th building (in meters) between 11 to NN.

3
4 1 3 1
4 4 4 3
5 3 3 2
Case #1: 4 1 3 2
Case #2: IMPOSSIBLE
Case #3: 2 1 5 5 3

Hint

In Sample Case #11, the sample output sets the height of each building such that only the first building is visible to Andre, while the first, third, and fourth buildings are visible to Sule. Therefore, only the first building is visible to both Andre and Sule. Note that there exist other correct solutions, such as 44 33 11 22.

In Sample Case #22, all N=4N = 4 buildings are visible to Andre and Sule. Therefore, it is impossible to have CNC \ne N in this case.

In Sample Case #33, the sample output sets the height of each building such that the first, third, and fourth buildings are visible to Andre, while the third, fourth, and fifth buildings are visible to Sule. Therefore, the third and fourth buildings are visible to both Andre and Sule. Note that there exist other correct solutions.

Limits

1T1001 \le T \le 100.

1CN1 \le C \le N.

CANC \le A \le N.

CBNC \le B \le N.

Test Set 11

1N51 \le N \le 5.

Test Set 22

1N1001 \le N \le 100.