60分求救,4个点RE
查看原帖
60分求救,4个点RE
957640
Michelle01楼主2023/8/27 13:03
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;

string a;
stack<char> s;
int main() {
	cin >> a;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == '(') {
			s.push(a[i]);
		}
		if (a[i] == ')') {
			if (s.top() == '(' and !s.empty()) {
				s.pop();
			}
		}
	}
	if (s.empty()) {
		cout << "YES";
		return 0;
	}
	cout << "NO";


	return 0;
}

2023/8/27 13:03
加载中...