You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
703 B
33 lines
703 B
#include<bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
const int N = 100010;
|
|
int a[N], b[N];
|
|
int stk[N], tt;
|
|
int n, q;
|
|
|
|
//纯模拟算法
|
|
int main() {
|
|
cin >> q;
|
|
while (q--) {
|
|
//清空栈
|
|
tt = 0;
|
|
|
|
//输入
|
|
cin >> n;
|
|
for (int i = 1; i <= n; i++) cin >> a[i];
|
|
for (int i = 1; i <= n; i++) cin >> b[i];
|
|
|
|
int head = 1;
|
|
for (int i = 1; i <= n; i++) {
|
|
stk[++tt] = a[i];
|
|
while (stk[tt] == b[head]) {
|
|
tt--;
|
|
head++;
|
|
if (tt == 0) break;
|
|
}
|
|
}
|
|
if (tt == 0) cout << "Yes" << endl;
|
|
else cout << "No" << endl;
|
|
}
|
|
} |