蒟蒻求解,只有70分
查看原帖
蒟蒻求解,只有70分
1275154
llyt楼主2024/8/10 11:54
#include<bits/stdc++.h>
using namespace std;
map<int,char> mp;
int main(){
    stack<char> s;
    char t;
    while(t!='@'){
        cin>>t;
        s.push(t);
    }
    s.pop();
    while(!s.empty()){
        if(s.top()=='('){
            mp['(']++;
            s.pop();
        }else if(s.top()==')'){
            mp[')']++;
            s.pop();
        }else{
            s.pop();
        }
    }
    if(mp[')']==mp['(']){
        cout<<"YES";
    }else cout<<"NO";
}

2024/8/10 11:54
加载中...