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

21927번 - Secrets of Legendary Treasure 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB120706860.714%

문제

Finally, you have discovered the document with two integer sequences, the final keys to unlocking the secret of the legendary treasure! The ink on the document, however, has faded so much that some of the numbers in the sequences are too faint to read. Fortunately, you have heard of a legend on the characteristics of the key sequences that (1) the numbers in the two sequences are all different and are between 1 and the sum of the lengths of the two sequences, and (2) both sequences are arranged in ascending order.

Please restore the original sequences from the readable numbers and the legend.

입력

The input consists of a single test case of the following format.

n m
a1 . . . an
b1 . . . bm

The first line consists of two integers n (1 ≤ n ≤ 100) and m (1 ≤ m ≤ 100). They are the lengths of the two sequences A and B, respectively. The second line describes the sequence A. Each ai is either 0, meaning that the i-th element of A is unreadable, or a positive integer 1 ≤ ai ≤ n + m meaning that the element reads ai. The third line describes the sequence B in the same fashion.

출력

Print a pair of restored sequences A and B in two lines. The sequences should be consistent with the input and the legendary characteristics of the sequences.

The elements of the sequence A should be printed in the first line, separated by a space character. Then the elements of the sequence B should be printed in the second line, in the same manner.

If there are multiple possibilities, print any one of such pairs. At least one sequence pair consistent with the input and conforming to the legend is guaranteed to exist.

제한

예제 입력 1

3 3
0 0 0
4 0 0

예제 출력 1

1 2 3
4 5 6

예제 입력 2

6 7
0 5 0 0 0 13
0 0 3 0 8 0 12

예제 출력 2

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

노트

Note that there are other acceptable outputs for the second sample input, such as the one with the positions of 6 and 7 exchanged.

출처

ICPC > Regionals > Asia Pacific > Japan > ICPC 2020 Asia Yokohama Regional B번

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

출처

대학교 대회

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

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