#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define PII pair<int,int >
#define int long long
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e6+10;
string s;
int va[N];
stack<char> st;
signed main()
{
IOS;
cin>>s;
int suc=1;
for(int i=0;i<s.size();i++)
{
if(s[i]=='('||s[i]=='[')
{
st.push(s[i]);
}
else
{
if(st.size()==0) suc=0;
else
{
char now=st.top();
st.pop();
if(s[i]==')'&&now=='[') suc=0;
if(s[i]==']'&&now=='(') suc=0;
}
}
}
if(st.size()>0) suc=0;
if(suc==1) cout<<"Ya";
else cout<<"Wrong";
return 0;
}
括弧匹配检验
最新推荐文章于 2024-07-22 09:38:37 发布