QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#1009 | #522637 | #9126. Number of Abbreviations | gzy | grass8cow | Failed. | 2024-10-17 15:46:13 | 2024-10-17 15:46:13 |
Details
Extra Test:
Invalid Input
input:
cabcasasss
output:
result:
FAIL Expected integer, but "cabcasasss" found (stdin, line 1)
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;
}