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

32570번 - Knitting 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB32191973.077%

문제

You are knitting a scarf in a striped pattern, having made strong progress on the first few stripes. You have multiple colours available to continue creating the pattern and would very much like that no colour appears too often -- more specifically, that the colour appearing most often still appears as few times as possible.

Figure K.1: A knitted solution to sample input 1. No colour is used more than twice, nor is any colour repeated within 3 consecutive stripes.

Please extend the given design to fashion a nice scarf.

입력

  • One line containing the number of stripes to create, $n,ドル the number of colours available, $k,ドル and the minimum spacing between stripes of the same colour, $p$ (1ドル \le n, k, p \le 10^5$).
  • One line containing the number of stripes already knitted, $m$ (1ドル \le m \le n$).
  • One line containing $m$ integers, the colours of the stripes $s_i$ (1ドル \le s \le k$).

The colours of the stripes are represented as integers in $[1{\ldots}k]$.

출력

Output any stripe pattern starting with $s_{1 \ldots m}$ that does not repeat any of the colours too soon and uses the most-frequent colour as few times as possible.

If it is not possible to create a scarf from the parameters, output impossible instead.

제한

예제 입력 1

10 6 3
4
4 1 6 4

예제 출력 1

4 1 6 4 1 5 2 3 6 5

예제 입력 2

5 2 3
2
1 2

예제 출력 2

impossible

예제 입력 3

2 2 3
1
2

예제 출력 3

2 1

예제 입력 4

10 26 5
4
8 3 16 3

예제 출력 4

impossible

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > The UK & Ireland Programming Contest > UKIEPC 2024 K번

  • 문제를 만든 사람: Robin Lee
(追記) (追記ここまで)

출처

대학교 대회

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

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