301516: CF286C. Main Sequence

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Main Sequence

题意翻译

定义幸运数列: 空数列是幸运数列 如果 S 是幸运数列,那么 {r, S, -r} 也是幸运数列 (r > 0) 如果 S 和 T 都是幸运数列,那么 {S, T} 也是幸运数列 给定一个幸运数列中每个数的绝对值,并且要求其中的一些数是负数,其他的可正可负。 问是否有合法方案,如果有,给出任意一种方案。 N ≤ 10^6 幸运数列例子:{1, 2, -2, -1, 1, -1, 1, -1} 输入:1 1 1 1 要求第三个数是负数 输出: 1 1 -1 -1

题目描述

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 $ {a_{1},a_{2},...,a_{l}} $ and $ {b_{1},b_{2},...,b_{k}} $ are correct bracket sequences, then sequence $ {a_{1},a_{2},...,a_{l},b_{1},b_{2},...,b_{k}} $ (their concatenation) also is a correct bracket sequence. - If $ {a_{1},a_{2},...,a_{l}} $ — is a correct bracket sequence, then sequence ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF286C/b33e2eedc865caf6f8fa1a0ee5d1acc87a898f62.png) also is a correct bracket sequence, where $ v $ $ (v&gt;0) $ is an integer. For example, sequences $ {1,1,-1,2,-2,-1} $ and $ {3,-3} $ are correct bracket sequences, and $ {2,-3} $ is not. Moreover, after Vova became a shaman, he learned the most important correct bracket sequence $ {x_{1},x_{2},...,x_{n}} $ , consisting of $ n $ integers. As sequence $ x $ is the most important, Vova decided to encrypt it just in case. Encrypting consists of two sequences. The first sequence $ {p_{1},p_{2},...,p_{n}} $ contains types of brackets, that is, $ p_{i}=|x_{i}| $ ( $ 1<=i<=n $ ). The second sequence $ {q_{1},q_{2},...,q_{t}} $ contains $ t $ integers — some positions (possibly, not all of them), which had negative numbers in sequence $ {x_{1},x_{2},...,x_{n}} $ . Unfortunately, Vova forgot the main sequence. But he was lucky enough to keep the encryption: sequences $ {p_{1},p_{2},...,p_{n}} $ and $ {q_{1},q_{2},...,q_{t}} $ . Help Vova restore sequence $ x $ 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 $ n $ ( $ 1<=n<=10^{6} $ ). The second line contains $ n $ integers: $ p_{1},p_{2},...,p_{n} $ $ (1<=p_{i}<=10^{9}) $ . The third line contains integer $ t $ ( $ 0<=t<=n $ ), followed by $ t $ distinct integers $ q_{1},q_{2},...,q_{t} $ $ (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 $ {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 $ n $ integers $ x_{1},x_{2},...,x_{n} $ $ (|x_{i}|=p_{i}; x_{qj}&lt;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

Input

题意翻译

定义幸运数列: 空数列是幸运数列 如果 S 是幸运数列,那么 {r, S, -r} 也是幸运数列 (r > 0) 如果 S 和 T 都是幸运数列,那么 {S, T} 也是幸运数列 给定一个幸运数列中每个数的绝对值,并且要求其中的一些数是负数,其他的可正可负。 问是否有合法方案,如果有,给出任意一种方案。 N ≤ 10^6 幸运数列例子:{1, 2, -2, -1, 1, -1, 1, -1} 输入:1 1 1 1 要求第三个数是负数 输出: 1 1 -1 -1

加入题单

算法标签: