/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 23ms 2.492 MiB
#3 Accepted 23ms 2.391 MiB
#4 Accepted 20ms 756.0 KiB
#5 Accepted 20ms 744.0 KiB
#6 Accepted 20ms 324.0 KiB
#7 Accepted 23ms 328.0 KiB
#8 Accepted 42ms 552.0 KiB
#9 Accepted 31ms 568.0 KiB

Code

#include<bits/stdc++.h>

//#include <Windows.h> Sleep(300);
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define mod 1000000007
#define log(args...){ string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cout<<endl; }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << " ";
	err(++it, args...);
}
#define fr(i, n) for(int i=0; i<n; i++)
#define fr1(i, n) for(int i=1; i<=n; i++)
#define fab(i, a, b) for(int i=a; i<b; i++)
const int dx[]={+1,-1,+0,+0};
const int dy[]={+0,+0,+1,-1};

int32_t main() {
    int t=1; cin>>t;

    while(t--){
        int n; cin>>n;
        string s; cin>>s;
		int count[26]={0};
		for(auto x: s) count[x-'a']++;
		int ans = 0;
		fr(i, 26) ans += count[i]*(count[i]-1);
		cout<<ans<<endl;
   }

}

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 16:43:29
Judged At
2024-10-03 13:49:36
Judged By
Score
100
Total Time
42ms
Peak Memory
2.492 MiB