#P13671. [GCPC 2023] Freestyle Masonry
[GCPC 2023] Freestyle Masonry
题目描述
Fred got a simple task, he just has to build a wall.
:::align{center} An interesting brick layout, photo by Bobo Boom :::
To make this even easier, he was provided with enough bricks and also a few bricks to complete the wall. Knowing that this task should not be too hard, Fred went to work and started building the wall without thinking too much about the design. Only when he ran out of bricks, Fred noticed that this might have been a bad idea...
:::align{center}
Figure F.1: Visualization of Sample Input 2. The red bricks have already been placed by Fred. The blue bricks still need to be placed to complete the wall (the only possible design in this case). :::
Maybe he should have made a plan before starting to build the wall, but now it is too late. Fred only has a bunch of bricks left and wants to finish the wall. Can he still complete it with the remaining bricks? Note that the wall to be built should have a width of exactly units and a height of exactly units.
输入格式
The input consists of:
- One line with two integers and (, ), the width and height of the wall Fred wants to build.
- One line with integers (), where is the current height of the wall at position .
输出格式
Output "" if Fred can complete his wall and "" otherwise.
3 3
0 0 1
possible
6 3
1 0 1 1 0 1
possible
6 2
1 0 1 1 0 1
impossible
5 2
1 2 3 2 2
impossible