我的 SB(S 组 B 题)代码:
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, ans, flag;
string str;
signed main(){
freopen("game.in", "r", stdin);
freopen("game.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> str;
str = ' ' + str;
for (auto i: str){
if (i != 'a' || i != 'b') flag = 1;
}
if (flag){
cout << 0;
return 0;
}
for (int l(1); l<=n; ++l){
stack<char, vector<char>> st;
for (int j(l); j<=n; ++j){
if (st.empty() || st.top() != str[j]) st.push(str[j]);
else st.pop();
ans += st.empty();
}
}
cout << ans;
return 0;
}
0 分。因为 flag 必定为真。所以输出必为 0。所以考试快要结束时一定要好好测一遍样例。
如果把这坨东西给删掉,即有 50 分。
没想到我是被这个搞走的……明年再见。