文章
105
粉丝
69
获赞
117
访问
57.5k
#include <bits/stdc++.h>
using namespace std;
string str;
int main()
{
cin >> str;
string stk1, stk2;
for(int i = 0; i < str.size(); i ++)
{
if(str[i] == '(') stk1.push_back(')');
else if(str[i] == '[') stk1.push_back(']');
else if(str[i] == ')') stk2.push_back('(');
else stk2.push_back(']');
if(str[i] == stk1.back())
{
stk1.pop_back();
stk2.pop_back();
}
}
if(stk1.empty() && stk2.empty()) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}
登录后发布评论
暂无评论,来抢沙发