#include<iostream>
using namespace std;
int main()
{
cin >> num;
string p;
getline(cin , p);
while(num--)
{
while(!s.empty()) s.pop();
getline(cin , p);//按行读入,可读入空串
for(int i = 0; i < p.size(); i++)
{
if(s.empty())
{
s.push(p[i]);
continue;
}
if(trans(p[i]) == s.top())
s.pop();
else s.push(p[i]);
}
if(s.empty()) printf("Yes\n");
else printf("No\n");
}
return 0;
}
UVA673 平衡的括号 Parentheses Balance——洛谷
最新推荐文章于 2021-09-09 19:16:36 发布