RE求助
查看原帖
RE求助
1104168
QiudaoYV楼主2023/11/17 14:04
#include <iostream>
#include <stack>
using namespace std;

int main() {
      int q,n;
      cin>>q;

      for(int i=0;i<q; ++i){
            int a[100010],p=1,x;
            stack <int> b;
            
            cin>>n;
            for(int j=0;j<n;++j) cin>>a[j];
            b.push(a[0]);
            
            for(int j=0;j<n;++j){
                  cin>>x;
                  if((!b.empty())&&b.top()==x) b.pop();
                  else{
                        while(a[p]!=x) b.push(a[p++]);
                        p++;
                  }
            }
            if(b.empty()) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;

      }

      return 0;
}

第一个测试点过了,但是其他的都是RE,求大佬指点
2023/11/17 14:04
加载中...