社区讨论
How ABC C
学术版参与者 7已保存回复 9
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 9 条
- 当前快照
- 1 份
- 快照标识符
- @mhj11vja
- 此快照首次捕获于
- 2025/11/03 18:58 4 个月前
- 此快照最后确认于
- 2025/11/03 18:58 4 个月前
太唐了,E题做出来,C题挂了(WA 11,TLE 6)
CPP#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int q,op;
string s;
char c;
vector<pair<int,bool> > ans;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>q;
ans.push_back({0,1});
while(q--){
cin>>op;
if(op==1){
cin>>c;
s=s+c;
int cv=ans.back().first;
bool cur=ans.back().second;
if(c=='(') cv++;
else{
cv--;
if(cv<0) cur=1;
}
ans.push_back({cv,cur});
}
else s.pop_back(),ans.pop_back();
if(ans.back().first==0&&ans.back().second) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}
思路好像没问题qwq
回复
共 9 条回复,欢迎继续交流。
正在加载回复...