求调RE+WA
查看原帖
求调RE+WA
1285326
wzjDD楼主2025/7/20 12:48
#include<bits/stdc++.h>
using namespace std;
stack<int> st;char a[10002];
int main(){
	int k,u = 0,n,m,s = 0,r;
	cin>>a;
	for(int i = 0;i < strlen(a);i++){
		if(st.empty()){
			if(a[i] == ')')st.push(0);
			else st.push(9);
			continue;
		}
		if(a[i] == ')' && st.top() == 9)
			st.pop();
		else {
			if(a[i] == ')')st.push(0);
			else st.push(9);
		}
	}
	cout<<st.size();
	return 0;  
}
2025/7/20 12:48
加载中...