/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 328.0 KiB
#2 Wrong Answer 26ms 2.434 MiB
#3 Wrong Answer 25ms 2.289 MiB

Code

#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin>>n;
        string s;
        cin>>s;
        int freq[26]={0};
        for (char c : s) {
            freq[c-'a']++;
        }
        // for(int i=0; i<26; i++)
        // {
        //     cout<<freq[i]<<" ";
        // }
        int summ=0;

        for(int i=0; i<26; i++)
        {
            if(freq[i]>1){
                summ += (freq[i]*(freq[i]-1));
            }
        }
        cout<<summ<<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:35:57
Judged At
2024-11-11 03:32:06
Judged By
Score
10
Total Time
26ms
Peak Memory
2.434 MiB