68分球球球球球球

P1241 括号序列

H2O2_ @ 2024-07-23 17:00:32

(╬ ̄皿 ̄) 气 思 了

(高超力)

#include<bits/stdc++.h>
using namespace std;
stack<int>ans;
queue<int>s;
int pushed[100010],popped[100010],m,xb=1,tmp,n;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        xb=1;
        memset(pushed,0,sizeof(pushed));
        memset(popped,0,sizeof(popped));
        while(!ans.empty())
            ans.pop();  

        while(!s.empty())
            s.pop();

        cin>>m;
        for(int j=1;j<=m;j++){cin>>tmp;s.push(tmp);}
        for(int j=1;j<=m;j++){cin>>popped[j];}      
        for(int j=1;j<=m;j++){
            ans.push(s.front());
            s.pop();
            if(ans.top()==popped[xb]){
                while(ans.top()==popped[xb]){
                    xb++;
                    ans.pop();
                    if(ans.empty())break;
                }
            }
        }
        xb--;
        if(xb!=m) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
} 

by KnowWind @ 2024-08-13 00:02:17

同68。。。。


by Duckh @ 2024-08-26 15:31:55

我也是,错了4个,但不知道那4个是啥,次数用光了。


|