/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 492.0 KiB
#2 Wrong Answer 40ms 2.492 MiB
#3 Wrong Answer 37ms 2.324 MiB

Code

#include <iostream>
#include<map>

using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin>>n;
        string str;
        cin>>str;

        map<char,int> freq;
        for (char c : str) {
            freq[c]++;
        }
        long long result = 0;
        for (auto p : freq) {
            int count = p.second;
            if (count >= 1) {
                result += count * (count - 1);
            }
        }
        cout << result << 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 17:36:42
Judged At
2024-11-11 03:32:05
Judged By
Score
10
Total Time
40ms
Peak Memory
2.492 MiB