/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 536.0 KiB
#2 Wrong Answer 55ms 1.473 MiB
#3 Wrong Answer 55ms 1.469 MiB
#4 Accepted 53ms 632.0 KiB
#5 Accepted 53ms 580.0 KiB
#6 Accepted 54ms 532.0 KiB
#7 Accepted 57ms 540.0 KiB
#8 Accepted 92ms 572.0 KiB
#9 Accepted 61ms 564.0 KiB

Code

#include <iostream>
#include <unordered_map>
using namespace std;

// SAYED AL MAMUN_LU

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        char samp[n];
        for (int h = 0; h < n; h++)
        {
            cin >> samp[h];
        }

        unordered_map<char, int> freq;
        for (int i = 0; i < n; i++)
        {
            freq[samp[i]]++;
        }

        int sum = 0;
        for (auto &[key, value] : freq)
        {
            sum += (value * (value - 1)) / 2;
        }

        cout << 2*sum << 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:54:00
Judged At
2024-10-03 13:47:46
Judged By
Score
80
Total Time
92ms
Peak Memory
1.473 MiB