CF286C.Main Sequence

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

As you know, Vova has recently become a new shaman in the city of Ultima Thule. So, he has received the shaman knowledge about the correct bracket sequences. The shamans of Ultima Thule have been using lots of different types of brackets since prehistoric times. A bracket type is a positive integer. The shamans define a correct bracket sequence as follows:

  • An empty sequence is a correct bracket sequence.
  • If a1,a2,...,al{a_{1},a_{2},...,a_{l}} and b1,b2,...,bk{b_{1},b_{2},...,b_{k}} are correct bracket sequences, then sequence a1,a2,...,al,b1,b2,...,bk{a_{1},a_{2},...,a_{l},b_{1},b_{2},...,b_{k}} (their concatenation) also is a correct bracket sequence.
  • If a1,a2,...,al{a_{1},a_{2},...,a_{l}} — is a correct bracket sequence, then sequence also is a correct bracket sequence, where vv (v>0) is an integer.

For example, sequences 1,1,1,2,2,1{1,1,-1,2,-2,-1} and 3,3{3,-3} are correct bracket sequences, and 2,3{2,-3} is not.

Moreover, after Vova became a shaman, he learned the most important correct bracket sequence x1,x2,...,xn{x_{1},x_{2},...,x_{n}} , consisting of nn integers. As sequence xx is the most important, Vova decided to encrypt it just in case.

Encrypting consists of two sequences. The first sequence p1,p2,...,pn{p_{1},p_{2},...,p_{n}} contains types of brackets, that is, pi=xip_{i}=|x_{i}| ( 1<=i<=n1<=i<=n ). The second sequence q1,q2,...,qt{q_{1},q_{2},...,q_{t}} contains tt integers — some positions (possibly, not all of them), which had negative numbers in sequence x1,x2,...,xn{x_{1},x_{2},...,x_{n}} .

Unfortunately, Vova forgot the main sequence. But he was lucky enough to keep the encryption: sequences p1,p2,...,pn{p_{1},p_{2},...,p_{n}} and q1,q2,...,qt{q_{1},q_{2},...,q_{t}} . Help Vova restore sequence xx by the encryption. If there are multiple sequences that correspond to the encryption, restore any of them. If there are no such sequences, you should tell so.

输入格式

The first line of the input contains integer nn ( 1<=n<=1061<=n<=10^{6} ). The second line contains nn integers: p1,p2,...,pnp_{1},p_{2},...,p_{n} (1<=pi<=109)(1<=p_{i}<=10^{9}) .

The third line contains integer tt ( 0<=t<=n0<=t<=n ), followed by tt distinct integers q1,q2,...,qtq_{1},q_{2},...,q_{t} (1<=qi<=n)(1<=q_{i}<=n) .

The numbers in each line are separated by spaces.

输出格式

Print a single string "NO" (without the quotes) if Vova is mistaken and a suitable sequence x1,x2,...,xn{x_{1},x_{2},...,x_{n}} doesn't exist.

Otherwise, in the first line print "YES" (without the quotes) and in the second line print nn integers x1,x2,...,xnx_{1},x_{2},...,x_{n} (|x_{i}|=p_{i}; x_{qj}<0) . If there are multiple sequences that correspond to the encrypting, you are allowed to print any of them.

输入输出样例

  • 输入#1

    2
    1 1
    0
    

    输出#1

    YES
    1 -1
    
  • 输入#2

    4
    1 1 1 1
    1 3
    

    输出#2

    YES
    1 1 -1 -1
    
  • 输入#3

    3
    1 1 1
    0
    

    输出#3

    NO
    
  • 输入#4

    4
    1 2 2 1
    2 3 4
    

    输出#4

    YES
    1 2 -2 -1
    
首页