/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Runtime Error 23ms 2.383 MiB
#3 Runtime Error 23ms 2.5 MiB
#4 Runtime Error 4ms 760.0 KiB
#5 Runtime Error 4ms 756.0 KiB
#6 Runtime Error 2ms 572.0 KiB
#7 Wrong Answer 24ms 552.0 KiB
#8 Wrong Answer 45ms 620.0 KiB
#9 Wrong Answer 36ms 556.0 KiB

Code

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

int main() {
    long long t;
    cin >> t;
    while(t--)
    {
        long long 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<n; 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++17 (G++ 13.2.0)
Submit At
2024-05-06 16:22:39
Judged At
2024-10-03 13:50:25
Judged By
Score
10
Total Time
45ms
Peak Memory
2.5 MiB