zhangchenyi_10_old @ 2024-06-30 17:18:38
#include <bits/stdc++.h>
using namespace std;
stack<int> pushed;
int poped[100010];
int q;
int n;
int main(){
scanf("%d",&q);
for(int i=1;i<=q;i++){
memset(poped,0,sizeof(poped));
scanf("%d",&n);
for(int j=1;j<=n;j++){
int x;
scanf("%d",&x);
pushed.push(x);
}
for(int j=1;j<=n;j++){
scanf("%d",&poped[j]);
}
bool flag=1;
for(int j=1;j<=n;j++){
if(pushed.top()!=poped[j]) flag=false,printf("%d %d",pushed.top(),poped[j]);
pushed.pop();
}
if(flag){
printf("Yes");
}
else{
printf("No");
}
printf("\n");
}
}
样例已过
by zts201210 @ 2024-06-30 17:32:46
怎么有调试语句?
if(pushed.top()!=poped[j]) flag=false/*,printf("%d %d",pushed.top(),poped[j])*/;