差3个点,求救!!!
查看原帖
差3个点,求救!!!
766220
Transparent_fish楼主2024/11/8 13:59
#include <bits/stdc++.h>
using namespace std;
const int N = 100000000;
int q, n, a, b[N], c[N], ans = 0;

int main() {
	stack<int> s;
	cin >> q;
	while (q--) {
		cin >> n;
		for (int j = 0; j < n; j++) {
			cin >> b[j];
		}
		for (int j2 = 0; j2 < n; j2++) {
			cin >> c[j2];
		}
		for (int j3 = 0; j3 < n; j3++) {
			s.push(b[j3]);
			while (s.top() == c[ans]) {
				s.pop();
				ans++;
				if (s.empty() == 1) {
					break;
				}
			}
		}
		if (s.empty()) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
		while (!s.empty()) {
			s.pop();
			ans=0;
		}
	}
	return 0;
}
2024/11/8 13:59
加载中...