行业知识
统计a字符右边是否有足够多的b字符与之匹配
2026-11-29 06:44:00
来源:互联网转载
for (char c : s) { if (c == 'a') { cnt++; } else { cnt = max(cnt - 1, 0ll); }} 23ccpc���林GProblem - G - Codeforces
()void solve() {std::string s;std::cin >> s;int cnt = 0;for (char c : s) {if (c == '(') {cnt++;}else {cnt = std::max(cnt - 1, 0);}}std::cout t; while (t--) {solve();}return 0;} 好串登录—专业IT笔试面试备考平台_牛客网
using ll=long long;void solve() {std::string s;std::cin >> s;ll cnt = 0,x=0,y=0;for (char c : s) {if (c == 'a') {cnt++; x++;}else {cnt = std::max(cnt - 1LL, 0LL); y++;}} if(s[0]=='b'||x!=y)cnt=1LL;std::cout
上一篇:云服务器找客户
下一篇:云储存服务器怎么用?