Accepted
Code
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define endl '\n'
#define Endl '\n'
using namespace std;
const int N = 2e5 + 5;
int tc, n, m, a[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); // cout.tie(0);
cin >> tc;
while (tc--) {
map<char, int> mp;
string s;
cin >> n >> s;
for (auto i : s) {
mp[i]++;
}
ll Ans = 0;
for (auto i : mp) {
ll cnt = i.S;
Ans += (cnt * (cnt - 1));
}
cout << Ans << endl;
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1038 Do not touch my string
- Contest
- Brain Booster #3
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-05-06 15:10:47
- Judged At
- 2024-11-11 03:35:01
- Judged By
- Score
- 100
- Total Time
- 57ms
- Peak Memory
- 1.637 MiB