Kaaras @ 2023-08-02 10:15:04
#include<iostream>
#include<istream>
#include<ostream>
#include<string>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;
int q,n[114514],pushed[11451419],poped[11451419],bock[11451419];
int main(){
cin>>q;
for(int j = 0;j < q;j++){
cin>>n[j];
for(int i = 0;i < n[j];i++) cin>>pushed[i];
for(int i = 0;i < n[j];i++) cin>>poped[i];
for(int i = n[j] - 1;i >= 0;i--){
int cnt = 0;
bock[cnt] = poped[i];
cnt++;
}
bool flag = false;
for(int i = 0;i < n[j];i++) if(pushed[i] != bock[i]) flag = true;
if(!flag) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}
by Patrick_Liu_Bingxian @ 2023-08-09 12:02:40
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<bitset>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
int main(){
int t;
cin>>t;
for(int k=1;k<=t;k++){
queue<int>q;
stack<int>s;
int n,a[100001],x;
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<=n;i++){
cin>>x;
q.push(x);
}
for(int i=1;i<=n;i++){
s.push(a[i]);
while(s.size()>0&&s.top()==q.front()){
s.pop();
q.pop();
}
}
if(s.size()==0)
cout<<"Yes\n";
else
cout<<"No\n";
}
return 0;
}
写了一下
我的代码,求关
by Kaaras @ 2023-08-15 09:35:59
谢谢,懂了,也关注了