Upload code_segments/segment_63.txt with huggingface_hub
Browse files- code_segments/segment_63.txt +25 -0
code_segments/segment_63.txt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sofia had an array of $n$ integers $a_1, a_2, \ldots, a_n$. One day she got bored with it, so she decided to sequentially apply $m$ modification operations to it.
|
| 2 |
+
|
| 3 |
+
Each modification operation is described by a pair of numbers $\langle c_j, d_j \rangle$ and means that the element of the array with index $c_j$ should be assigned the value $d_j$, i.e., perform the assignment $a_{c_j} = d_j$. After applying all modification operations sequentially, Sofia discarded the resulting array.
|
| 4 |
+
|
| 5 |
+
Recently, you found an array of $n$ integers $b_1, b_2, \ldots, b_n$. You are interested in whether this array is Sofia's array. You know the values of the original array, as well as the values $d_1, d_2, \ldots, d_m$. The values $c_1, c_2, \ldots, c_m$ turned out to be lost.
|
| 6 |
+
|
| 7 |
+
Is there a sequence $c_1, c_2, \ldots, c_m$ such that the sequential application of modification operations $\langle c_1, d_1, \rangle, \langle c_2, d_2, \rangle, \ldots, \langle c_m, d_m \rangle$ to the array $a_1, a_2, \ldots, a_n$ transforms it into the array $b_1, b_2, \ldots, b_n$?
|
| 8 |
+
|
| 9 |
+
The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.
|
| 10 |
+
|
| 11 |
+
Then follow the descriptions of the test cases.
|
| 12 |
+
|
| 13 |
+
The first line of each test case contains an integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the size of the array.
|
| 14 |
+
|
| 15 |
+
The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the original array.
|
| 16 |
+
|
| 17 |
+
The third line of each test case contains $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the found array.
|
| 18 |
+
|
| 19 |
+
The fourth line contains an integer $m$ ($1 \le m \le 2 \cdot 10^5$) — the number of modification operations.
|
| 20 |
+
|
| 21 |
+
The fifth line contains $m$ integers $d_1, d_2, \ldots, d_m$ ($1 \le d_j \le 10^9$) — the preserved value for each modification operation.
|
| 22 |
+
|
| 23 |
+
It is guaranteed that the sum of the values of $n$ for all test cases does not exceed $2 \cdot 10^5$, similarly the sum of the values of $m$ for all test cases does not exceed $2 \cdot 10^5$.
|
| 24 |
+
|
| 25 |
+
Output $
|