/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 2ms 540.0 KiB
#2 Wrong Answer 38ms 2.398 MiB

Code

#include <bits/stdc++.h>

using namespace std;

int count(string s) {
    int n = s.length();
    vector<int> frequency(26, 0);
    for(char c : s) {
        frequency[c - 'a']++;
    }
    int result = 0;
    for(int i = 0; i < 26; i++) {
        result += frequency[i] * (frequency[i] - 1) / 2;
    }
    return result;
}

int main() {
    int t;
    cin >> t;

    while(t--) {
        int n;
        cin >> n;
        string s;
        cin >> s;
        cout << count(s) << 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 15:43:30
Judged At
2024-11-11 03:33:57
Judged By
Score
0
Total Time
38ms
Peak Memory
2.398 MiB