一本通 RE
  • 板块灌水区
  • 楼主ht__QAQ__
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/7/10 21:29
  • 上次更新2023/11/3 10:39:19
查看原帖
一本通 RE
868193
ht__QAQ__楼主2023/7/10 21:29

http://ybt.ssoier.cn:8088/problem_show.php?pid=1203

应该是爆stack了不知道怎么改

#include<bits/stdc++.h>
#define int long long
using namespace std;
struct Node{
	int z;char c;
};
signed main(){
	string a;
	while(cin>>a){
		cout<<a<<'\n';
		Node tmp;stack<Node>s;
		for(int i=0;i<a.size();i++){
			if(a[i]=='('){
				tmp.z=i;
				tmp.c='(';
				s.push(tmp);
			}
			if(a[i]==')'){
				if(s.size()>0) s.pop();
				else{
					tmp.z=i;
					tmp.c='B';
					s.push(tmp);
				}
			}
		}
		int si=s.size();
		for(int i=0;i<a.size();i++){
			if(s.top().z==i){
				cout<<"$";
				if(s.size()>0)s.pop();
			}else if(s.top().z==i&&s.top().c=='B'){
				cout<<"?";
				if(s.size()>0)s.pop();
			}else{
				cout<<" ";
			}
		}
		cout<<"\n";
	}
    return 0;
}
2023/7/10 21:29
加载中...