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

31493번 - Broken trophy 스페셜 저지다국어

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

문제

Coming back home after triumphally winning your long-coveted trophy, you discover that it was shattered to pieces in your trunk. It just remains to repair it.

Your trophy had the shape of a rectangle of size 3ドル \times N,ドル for some integer $N \ge 1,ドル thereby consisting of 3ドル$ lines and $N$ columns, containing a total of 3ドルN$ unit squares. It was broken into $K$ pieces, the $k$th piece being a rectangle of size $A_k \times B_k$ for some integers $A_k$ and $B_k$ such that 1ドル \le A_k \le B_k \le 3$. Such pieces may have been rotated, or even flipped, in the havoc that is your trunk.

As the first step towards repairing your trophy, you should reassemble them in the form of a rectangle of size 3ドル \times N$. More precisely, you have drawn, on a sheet of paper, a 3ドル \times N$ rectangle on which you will place your $K$ pieces, and you need to know, for all integers $i \le 3$ and $j \le N,ドル which piece will cover the unit square on the $i$th line and $j$th column of your rectangle.

입력

The input consists of three lines, each one containing space-separated integers. The first line contains the numbers $K$ and $N$. The second line contains the numbers $A_1, A_2, \dots , A_K$. The third line contains the numbers $B_1, B_2, \dots, B_K$.

출력

The output should contain three lines, each one consisting of $N$ space-separated integers. If you plan to cover the unit square on the $i$th line and $j$th column with the $k$th piece, the $j$th number on the $i$th output line should be the integer $k$.

In case there are several ways to reassemble your pieces in the form of a rectangle of size 3ドル \times N,ドル every output representing one of these ways is considered correct.

제한

  • 1ドル \le K \le 300,円 000$
  • 1ドル \le N \le 100,円 000$
  • 1ドル \le A_k \le B_k \le 3$ for all $k \le K$
  • the pieces described in the input can be reassembled in the form of a rectangle of size 3ドル \times N$.

예제 입력 1

16 17
1 2 1 1 2 1 2 1 1 1 1 1 2 2 1 1
3 3 1 3 2 3 3 1 1 2 2 3 3 3 1 3

예제 출력 1

1 2 2 2 12 6 4 13 13 16 16 16 9 10 10 7 7
1 2 2 2 12 6 4 13 13 5 5 14 14 14 11 7 7
1 3 15 8 12 6 4 13 13 5 5 14 14 14 11 7 7

This output represents the following reassembling:

예제 입력 2

16 17
1 2 1 1 2 1 2 1 1 1 1 1 2 2 1 1
3 3 1 3 2 3 3 1 1 2 2 3 3 3 1 3

예제 출력 2

4 2 2 2 1 1 1 7 7 6 6 6 10 10 15 14 14
4 2 2 2 16 16 16 7 7 5 5 13 13 13 9 14 14
4 11 11 3 12 12 12 7 7 5 5 13 13 13 8 14 14

This output represents the following reassembling:

Both reassemblings are valid, even though sample inputs 1 and 2 are the same.

힌트

출처

ICPC > Regionals > Europe > Southwestern European Regional Contest > SWERC 2023-2024 L번

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

출처

대학교 대회

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

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