Accepted
Code
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int t; cin >> t;
while (t--) {
int n, ans (0); string s;
cin >> n >> s;
map<char,int> L, R;
for (auto& x:s) R[x]++;
for (auto& x:s) {
L[x]++; R[x]--;
for (char c('a'); c <= 'z'; c++) {
if ((L[c] == R[c]) && (c != x) && L[c] != 0) {
ans++; break;
}
}
}
cout << ans << '\n';
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1021 Pivot points
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-03-26 15:57:27
- Judged At
- 2024-11-11 03:40:12
- Judged By
- Score
- 100
- Total Time
- 39ms
- Peak Memory
- 568.0 KiB