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

23730번 - Guessing Answers 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB (추가 메모리 없음)56921415837.709%

문제

Yunee did not study for the final exam. So Yunee decided to guess the answers to all problems in the final exam. The final exam consists of $N$ single choice questions numbered from 1ドル$ to $N,ドル each with a choice of 1ドル$ to 5ドル$.

Yunee gets anxious when the answers to two successive problems are the same. So Yunee always selects an answer different from the answer to the previous problem (except for the first problem). After submitting the answers, Yunee received the grading result, which stated whether each answer was correct.

Given the correct answers to all problems and the $M$ problems that Yunee guessed correctly, reconstruct a possible sequence of Yunee's answers. It is guaranteed that at least one such sequence exists for each input.

입력

The first line contains two integers $N$ and $M$ $(1 \leq N \leq 100,000, 1\leq M \leq N)$. $N$ is the total number of problems. $M$ is the number of problems that Yunee guessed correctly.

The second line contains $N$ integers from 1ドル$ to 5ドル$. The $i$-th integer represents the correct answer to the $i$-th problem.

The third line contains $M$ distinct integers from 1ドル$ to $N$. They represent the $M$ problems that Yunee guessed correctly.

출력

Output a possible sequence of Yunee's answers. Each number should be separated by a blank.

제한

예제 입력 1

4 2
1 1 2 3
1 4

예제 출력 1

1 5 4 3

In the first example, suppose Yunee submitted the answers 1,ドル 5, 4, 3$. Since the correct answers are 1,ドル 1, 2, 3,ドル Yunee correctly guessed problems 1ドル$ and 4ドル$.

예제 입력 2

3 2
1 2 3
1 3

예제 출력 2

1 4 3

힌트

출처

University > UNIST > 3rd UNIST Algorithm Programming Contest Uni-CODE 2021 A번

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

출처

대학교 대회

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

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