/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 6ms 1.418 MiB
#3 Accepted 6ms 1.629 MiB
#4 Accepted 4ms 776.0 KiB
#5 Accepted 4ms 820.0 KiB
#6 Accepted 3ms 580.0 KiB
#7 Accepted 5ms 580.0 KiB
#8 Accepted 23ms 596.0 KiB
#9 Accepted 22ms 572.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,n) for(ll i=0;i<n;i++)
#define m(a,b,c) max(a,max(b,c))
#define N ll n;cin >> n;
#define Nk ll n,k;cin >> n >> k;
#define A ll a[n];f(i,n) cin >> a[i];
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr);
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define S string s;cin>>s;
#define pb push_back

int main()
{
   FAST_IO;
   ll t;
   cin>>t;
   while(t--)
   {
       N;
       S;
       ll c[26]={0};
       f(i,n)
       {
           c[s[i]-'a']++;
       }
       ll d=0;
       f(i,26)
       {
           d+=c[i]*(c[i]-1);
       }
       cout<<d<<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 15:45:36
Judged At
2024-11-11 03:33:53
Judged By
Score
100
Total Time
23ms
Peak Memory
1.629 MiB