| Codeforces Round 1099 (Div. 2) |
|---|
| Finished |
521 sounds the same as "I love you" in Chinese. On this special day, Little S wants to give Little A some well-prepared sequences to recall their friendship sealed for years.
Little S has prepared an array $$$a_1, a_2, \ldots, a_n$$$. Let's define its prefix sums array $$$b_1, b_2, \ldots, b_n$$$, where $$$b_i = a_1 + a_2 + \ldots + a_i$$$. Also define the prefix maximum array of $$$b$$$: $$$c_1, c_2, \ldots, c_n$$$, where $$$c_i = \max(b_1, b_2, \ldots, b_i)$$$.
Now array $$$a$$$ has been partially lost, but luckily Little S still keeps the array $$$c$$$. Your task is to restore the array $$$a$$$ and send it to Little A, or report that no such array exists — in this case, the kind and cute Little A won't get mad either.
Formally, you are given a binary string $$$s$$$, a partially filled array $$$a$$$, and an array $$$c$$$, where:
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$).
The second line of each test case contains a binary string $$$s$$$ ($$$s_i \in \{\texttt{0}, \texttt{1}\}$$$) of length $$$n$$$.
The third line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$|a_i| \le 10^6$$$). If $$$s_i = \texttt{0}$$$, then it is guaranteed that $$$a_i = 0$$$.
The fourth line of each test case contains $$$n$$$ integers $$$c_1, c_2, \ldots, c_n$$$ ($$$|c_i| \le 2 \cdot 10^{11}$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, print "Yes" in the first line if the array $$$a$$$ exists, otherwise print "No". You may print the answer in any case. For example, "YeS", "YES", "NO", "nO" will also be accepted.
If there is at least one solution, print $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$|a_i| \leq 10^{18}$$$) in the second line. If there are multiple suitable arrays, you may print any of them.
10411101 2 -1 01 3 3 35000010 0 0 0 5-4 -4 -1 -1 -1110160011110 0 2 -3 3 -6-5 -2 0 0 0 05111101 2 0 5 01 2 2 7 62010 1-1 -160010100 0 5 0 3 03 3 4 9 13 1660001000 0 0 4 0 02 6 6 7 7 72000 04 -18111111116 1 1 2 0 5 1 96 7 8 10 10 15 16 25
Yes 1 2 -1 0 Yes -4 0 3 -6 5 No Yes -5 3 2 -3 3 -6 No No No Yes 2 4 -3 4 -100 0 No Yes 6 1 1 2 0 5 1 9
In the first test case, we have:
In the third test case, the correct array $$$a$$$ should be equal to $$$[1]$$$, so no solution exists.
| Name |
|---|


