Accepted
Code
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
int t;
cin >> t;
while (t--){
ll n, ans = 0;
string s;
vector<ll> a(26);
cin >> n >> s;
for (int i = 0; i < n; i++){
a[s[i] - 97]++;
}
for (int i = 0; i < 26; i++){
ans += (a[i] * (a[i] - 1));
}
cout << ans << endl;
}
}
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:53:52
- Judged At
- 2024-11-11 03:33:43
- Judged By
- Score
- 100
- Total Time
- 44ms
- Peak Memory
- 2.664 MiB