/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 332.0 KiB
#2 Wrong Answer 38ms 2.426 MiB
#3 Wrong Answer 38ms 2.398 MiB
#4 Accepted 55ms 764.0 KiB
#5 Accepted 67ms 764.0 KiB
#6 Accepted 71ms 572.0 KiB
#7 Accepted 72ms 540.0 KiB
#8 Accepted 145ms 572.0 KiB
#9 Accepted 85ms 572.0 KiB

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-10-03 13:48:20
Judged By
Score
80
Total Time
145ms
Peak Memory
2.426 MiB