为什么会运行时错误
  • 板块学术版
  • 楼主czx2021
  • 当前回复4
  • 已保存回复4
  • 发布时间2024/10/23 22:50
  • 上次更新2024/10/24 10:27:40
查看原帖
为什么会运行时错误
565698
czx2021楼主2024/10/23 22:50

RT

#include<bits/stdc++.h>
#define ll long long
using namespace std;
string s;
stack<char>s1;
ll cnt;
int main()
{
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
    	if(s[i]=='(')s1.push(s[i]);
    	if(s[i]==')')
    	{
    		if(s1.top()=='(')s1.pop();
    		else s1.push(s[i]);
		 } 
	}
	cout<<s1.size();
   return 0;
}

https://iai.sh.cn/problem/614

2024/10/23 22:50
加载中...