ask666UU @ 2024-07-27 14:26:21
··
#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;
const int maxn=1e5+10;
int n,pu[maxn];
int T;
int main() {
scanf("%d",&T);
while(T--) {
stack<int> p;
scanf("%d",&n);
int cnt=2;
for(int i=1; i<=n; i++) scanf("%d",&pu[i]);
p.push(pu[1]);
for(int i=1; i<=n; i++) {
int u;
scanf("%d",&u);
while(p.top() != u&&cnt!=n) {
p.push(pu[cnt]);
// if(cnt == n) break;
cnt++;
}
if(p.top()==u)
p.pop();
}
if(!p.empty()) cout<<"No"<<endl;
else cout<<"Yes"<<endl;
// while(!p.empty()) p.pop();
}
return 0;
}
by ask666UU @ 2024-07-27 14:26:56
玄关
by 2022_37_yzyUUU @ 2024-07-29 10:07:08
捕捉ask
by 2022_37_yzyUUU @ 2024-07-29 10:13:09
#include<bits/stdc++.h>
using namespace std;
int q;
int n,x,pu[100001],po[100001],top=1;
int main(){
cin>>q;
while(q--){
top=1;
stack<int> s;
cin>>n;
top=1;
for(int i=1;i<=n;i++){
cin>>pu[i];
}
for(int i=1;i<=n;i++){
cin>>po[i];
}
for(int i=1;i<=n;i++){
s.push(pu[i]);
while(s.top()==po[top]){
s.pop();
top++;
if(s.empty())break;
}
}
if(s.empty())cout<<"Yes\n";
else cout<<"No\n";
}
return 0;
}
SP8624
by ask666UU @ 2024-07-30 11:10:32
捕捉UUU
by ask666UU @ 2024-07-30 11:11:27
所以我的代码哪里挂了???
by ask666UU @ 2024-07-30 11:13:12
@2022_37_yzyUUU
by IOI_official @ 2024-07-30 19:26:55
捕捉ask