Logo
(追記) (追記ここまで)

30899번 - Brickwork 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 (추가 시간 없음) 1024 MB116301833.962%

문제

Bob the Builder is tired of building tiny houses and paving narrow roads, and he strives for something bigger. The new job given to him by a very eccentric client is exactly what he needs: He is tasked with building a wall of a certain width that is infinitely high! His client assured him that he does not need to worry about the building material, and that an infinite supply of various kinds of bricks has already been ordered for him. Of course, building a stable wall takes very careful planning, especially if it is supposed to be infinitely high. In particular, a wall is only stable if no two gaps between bricks in consecutive rows end up directly above each other, as shown in Figure B.1. Bob knows from his long-time experience that if it is possible to build such a wall, then it can be done by alternating just two row configurations.

Figure B.1: On the left, we see an unstable wall using the brick types of Sample Input 1. On the right, we see a stable wall using the same brick types. Note that even though only two rows of the wall are shown, it is possible to build an infinitely high wall by repeating these two row configurations.

Bob is terribly excited about the new job and quickly goes to work. Given the types of bricks available, is it possible to build a stable wall of width exactly $w$ and infinite height? If yes, how should Bob build it using only two alternating row configurations?

입력

The input consists of:

  • One line with two integers $n$ and $w$ $(1\leq n,w\leq3\cdot10^5),ドル the number of brick types and the width of the wall.
  • One line with $n$ integers $b$ (1ドル\leq b\leq w$), the widths of the brick types.

Note that Bob has an infinite supply of all brick types.

출력

If it is possible to build a wall, then output "possible". Otherwise, output "impossible".

If a wall can be built, provide two row configurations that can be used in an alternating fashion. For both rows, first output the number of bricks needed for that row, followed by the lengths of the bricks in the order you want to use them. Your solution is considered valid if alternating the two rows infinitely would result in a stable wall.

If there are multiple valid solutions, you may output any one of them.

제한

예제 입력 1

4 12
3 2 7 2

예제 출력 1

possible
5
2 2 3 2 3
3
3 2 7

예제 입력 2

3 11
6 7 8

예제 출력 2

impossible

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > NWERC 2023 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /