QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#1011 | #522637 | #9126. Number of Abbreviations | xieliren | grass8cow | Failed. | 2024-10-17 15:51:09 | 2024-10-17 15:51:14 |
Details
Extra Test:
Accepted
time: 0ms
memory: 3848kb
input:
6 abbbaa
output:
15
result:
ok "15"
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#522637 | #9126. Number of Abbreviations | grass8cow# | AC ✓ | 3ms | 4464kb | C++17 | 286b | 2024-08-17 09:56:54 | 2024-08-17 09:56:54 |
answer
#include<bits/stdc++.h>
using namespace std;
char c[500100];
int t[26],n;
int main(){
scanf("%d%s",&n,c+1);
for(int i=1;i<=n;i++)t[c[i]-'a']++;
long long ans=0;
for(int i=0;i<26;i++)ans+=1ll*t[i]*(n-t[i]);
ans/=2,ans+=n;printf("%lld",ans);
return 0;
}