Accepted
Code
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
using ll = long long;
int main() {
FAST;
int tc = 1, ti;
cin >> tc;
for (ti = 1; ti <= tc; ++ti) {
ll n, ans;
string s;
cin >> n >> s;
map<char,ll> mp;
for (char c : s) mp[c] += 1;
ans = 0;
for (auto [_, cnt] : mp) ans += cnt*(cnt-1);
cout << ans << "\n";
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1038 Do not touch my string
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-10-03 20:23:54
- Judged At
- 2024-11-11 02:44:31
- Judged By
- Score
- 100
- Total Time
- 63ms
- Peak Memory
- 1.465 MiB