/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 22ms 2.496 MiB
#3 Wrong Answer 22ms 2.355 MiB
#4 Accepted 40ms 764.0 KiB
#5 Accepted 45ms 760.0 KiB
#6 Accepted 45ms 532.0 KiB
#7 Accepted 52ms 320.0 KiB
#8 Accepted 91ms 576.0 KiB
#9 Accepted 62ms 548.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:19:13
Judged At
2024-10-03 13:48:46
Judged By
Score
80
Total Time
91ms
Peak Memory
2.496 MiB