P4387 [Deep Basics 15.Exercise 9] Validate Stack Sequences
Description
Given two sequences pushed and poped, whose values range from $1$ to $n$ $(n \le 100000)$. The push sequence is known to be pushed. If the pop sequence could be poped, output `Yes`; otherwise output `No`. Note that the given sequences are guaranteed to be a **permutation** (i.e., there are no repeated numbers).
To prevent hacking, each test point contains multiple testdata sets, no more than $5$ sets.
Input Format
The first line contains an integer $q$, the number of queries.
Next come $q$ queries. For each query:
The first line contains an integer $n$, the length of the sequence.
The second line contains $n$ integers, the push sequence.
The third line contains $n$ integers, the pop sequence.
Output Format
For each query, output the answer.
Explanation/Hint
Translated by ChatGPT 5