玄关,愿帮助啦

UVA673 Parentheses Balance

样例没过哟~~~ 再检查检查吧 @[lucy2012](/user/1252442)
by liuruiqing @ 2024-04-27 22:43:04


@[liuruiqing](/user/1118614) 已更,样例输出良好QwQ ```cpp #include<bits/stdc++.h> using namespace std; stack<char> a; string p,s; char ch; int n; int main(){ cin>>n; getline(cin,p); for(int i=1;i<=n;i++){ cin>>s; if(s==""){ cout<<"Yes"; break; } for(int i=0;i<s.length();i++){ if(!a.empty()&&a.top()=='('&&s[i]==')') a.pop(); else if(!a.empty()&&a.top()=='['&&s[i]==']') a.pop(); else a.push(s[i]); } if(a.empty()) cout<<"Yes"<<endl; else cout<<"No"<<endl; while(!a.empty()) a.pop(); } return 0; } ```
by lucy2012 @ 2024-04-28 09:10:24


过不了是因为评测系统的原因吗?
by lucy2012 @ 2024-04-28 09:11:15


@[lucy2012](/user/1252442) UVA的题必须要有UVA账号。
by __ycx2010__ @ 2024-04-28 11:47:14


@[__ycx2010__](/user/819929) 我已经绑定了
by lucy2012 @ 2024-04-28 11:48:25


1. for外面getline是什么意思 2. 特判空串里面怎么是break 3. s.size()可能比s.length()更好 @[lucy2012](/user/1252442)
by liuruiqing @ 2024-04-28 15:48:11


|