/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Wrong Answer 17ms 1.465 MiB
#3 Wrong Answer 17ms 1.422 MiB

Code

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

long long fact(long long x){
	long long res = 1;
	for(long long i=1;i<=x;i++){
		res *= i;
	}
	return res;
}

int main(){
	ios :: sync_with_stdio(false);
	cin.tie(0);
	
	int tc;
	cin>>tc;
	while(tc--){
		int n;
		cin>>n;
		string str;
		cin>>str;
		if(n<2){
			cout<<"0\n";
		}
		else{
			unordered_map<char,long long>ump;
			for(int i=0;i<n;i++){
				ump[str[i]]++;
			}
			long long ans = 0;
			for(auto it:ump){
				if(it.second >=2){
					ans += fact(it.second)/2;
				}
			}
			cout<<ans*2<<endl;
		}
	}
	return 0;
}

Information

Submit By
Type
Submission
Problem
P1038 Do not touch my string
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-07 08:03:02
Judged At
2024-11-11 03:31:07
Judged By
Score
10
Total Time
17ms
Peak Memory
1.465 MiB