Wrong Answer
Code
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int count(const string& s) {
int n = s.length();
if (n == 1) {
return 0;
}
vector<int> count(26, 0);
for (char c : s) {
count[c - 'a']++;
}
int pairs = 0;
for (int c : count) {
pairs += c * (c - 1) / 2;
}
return pairs;
}
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
string s;
cin >> s;
int pairs = count(s);
cout << pairs << endl;
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1038 Do not touch my string
- Contest
- Brain Booster #3
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-05-06 16:09:36
- Judged At
- 2024-11-11 03:33:24
- Judged By
- Score
- 0
- Total Time
- 26ms
- Peak Memory
- 2.527 MiB