样例能过,但全WA
查看原帖
样例能过,但全WA
613598
mmy129楼主2022/8/9 22:09
#include<bits/stdc++.h>
using namespace std;
stack<char> s;
long long n;
string x;
int main(){
	cin>>n;
	while(n--){
		cin>>x;
		for(int i=0;i<x.length();i++){
			if(s.empty()){
				s.push(x[i]);
				continue;
			}
			if(s.top()=='('&&x[i]==')')s.pop();
				else if(s.top()=='['&&x[i]==']')s.pop();
					else if(s.top()=='{'&&x[i]=='}')s.pop();
						else s.push(x[i]);
		}
		if(s.empty())cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		while(!s.empty())s.pop();
	}
	return 0; 
}
2022/8/9 22:09
加载中...