khMakarov @ 2022-01-29 15:09:52
#include<iostream>
#include<stack>
#include<algorithm>
using namespace std;
stack<int> stk;
int n, m, k;
int main() {
cin >> n;
int cnt = 0, r = 0;
while (n--) {
cin >> m;
for (int i = 1; i <= m; i++) {
cin >> k;
stk.push(k);
}
for (int i = 1; i <= m; i++) {
cin >> k;
if (k != stk.top() && cnt == 0) {
cout << "NO" << endl;
r = 1;
cnt++;
}
stk.pop();
}
if (!r)cout << "YES" << endl;
}
return 0;
}
by coldy_rainy @ 2022-01-29 15:15:50
@khMakarov
题目要求输出的不全是大写哟
如果出栈序列有可能是 poped,则输出 Yes,否则输出 No
by khMakarov @ 2022-01-29 16:36:19
@penhaochen 确实是,太尴尬了 但还是全WA了。
by khMakarov @ 2022-01-29 16:56:18
我现在改成输入完了再输出还是全wa,不理解这道题明明感觉很水
for (int i = 1; i <= m; i++) {
cin >> k;
if (k != stk.top()) r = 1;
stk.pop();
}
if (!r)cout << "Yes" << endl;
if (r) cout << "No" << endl;
}
return 0;
}