B. 【深基15.习9】验证栈序列

    Type: RemoteJudge 1000ms 125MiB

【深基15.习9】验证栈序列

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

给出两个序列 pushed 和 poped 两个序列,其取值从 1 到 n(n100000)n(n\le100000)。已知入栈序列是 pushed,如果出栈序列有可能是 poped,则输出 Yes,否则输出 No。请注意,给定的序列一定是一个排列(即没有重复数字)。

为了防止骗分,每个测试点有多组数据,不超过 55 组。

输入格式

第一行一个整数 qq,询问次数。

接下来 qq 个询问,对于每个询问:

第一行一个整数 nn 表示序列长度;

第二行 nn 个整数表示入栈序列;

第三行 nn 个整数表示出栈序列;

输出格式

对于每个询问输出答案。

2
5
1 2 3 4 5
5 4 3 2 1
4
1 2 3 4
2 4 1 3
Yes
No

0724

Not Attended
Status
Done
Rule
IOI
Problem
4
Start at
2024-7-24 9:00
End at
2024-7-24 12:30
Duration
3.5 hour(s)
Host
Partic.
29