_Hu_Tao @ 2022-09-04 20:48:25
求助!代码如下
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
for(int i=1;i<=n;i++){
stack<int>stk;
int nn,f=1;
cin>>nn;int shun[100005]={0};
int x;
for(int i=1;i<=nn;i++){
cin>>shun[i];
}
stk.push(0);
for(int j=1;j<=nn;j++){
cin>>x;
for(int i=1;i<=nn+1;i++){
if(stk.top()<x){
if(shun[i]>=0){
stk.push(shun[i]);
}
shun[i]=-1;
}else if(stk.top()==x){
stk.pop();
break;
}else if(stk.top()>x){
cout<<"No"<<endl;
f=0;
break;
}
}
if(f==0){
break;
}
}
if(f==0){
continue;
}
if(!stk.empty()&&stk.top()==0){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
while(!stk.empty())stk.pop();
}
}
by Pozhu @ 2022-09-07 21:09:44
注意题干中说的“取值从 !
by Pozhu @ 2022-09-07 21:10:11
抱歉我吃掉了几乎所有标点符号(((