小图灵测得……
#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 2e6 + 5;
long long n, top, ans;
char sta[kMaxN];
string s;
int main() {
freopen("game.in", "r", stdin);
freopen("game.out", "w", stdout);
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> s;
s = " " + s;
for (int i = 1; i <= n; i++) {
top = 0;
if (clock() >= 980) {
return cout << ans, 0;
}
for (int j = i; j <= n; j++) {
sta[++top] = s[j];
if (top >= 2 && sta[top] == sta[top - 1]) {
top -= 2;
}
ans += (top == 0);
}
}
cout << ans;
return 0;
}
期望50