QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#748236#4774. Please, go firstgyydp123_LIMAC ✓1ms3824kbC++201.1kb2024-11-14 19:47:022024-11-14 19:47:02

Judging History

你现在查看的是最新测评结果

  • [2024-11-14 19:47:02]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3824kb
  • [2024-11-14 19:47:02]
  • 提交

answer

//Start: 2024-11-14 19:43:40
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=(j);i<=(k);++i)
#define ForDown(i,j,k) for(int i=(j);i>=(k);--i)
#define Debug(fmt, args...) fprintf(stderr,"(func %s, line #%d): " fmt, __func__, __LINE__, ##args),fflush(stderr)
#define debug(fmt, args...) fprintf(stderr,fmt,##args),fflush(stderr)
#define within :
#define LJY main
using namespace std;
typedef long long ll;
const int N=1e5+5;
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
inline int read(){
  char ch=getchar();int x=0,f=1;
  while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
  while(ch>='0'&&ch<='9')
    x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
  return x*f;
}
int n;char s[N];
int Mx[128],cnt[128];bool vis[128];
void ljy(){
  For(i,0,127) Mx[i]=cnt[i]=vis[i]=0;
  n=read();scanf("%s",s+1);
  For(i,1,n) Mx[s[i]]=i,cnt[s[i]]++;
  ll now=0,res=0;
  For(i,0,127) now+=(ll)cnt[i]*Mx[i];
  int lst=n;
  ForDown(i,n,1) if(!vis[s[i]]){
    vis[s[i]]=1;
    res+=lst*cnt[s[i]];
    lst-=cnt[s[i]];
  }printf("%lld\n",(now-res)*5);
}
signed LJY(){int T=read();while(T--) ljy();}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3760kb

input:

2
6
AABABB
10
Ab9AAb2bC2

output:

15
45

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

30
6
AABABB
10
Ab9AAb2bC2
1
R
2
ba
3
0b0
3
666
11
BACADAEAFAG
33
ooolll444PPyygg99YYIIrrol4Pyg9YIr
50
EJTdfKePfCTUZpcYkQQROhJCaaNBTFAYMRJBclQPnhjUfUCXkR
75
BCCACCBBAACACCBABCAAAACACCACBAACCAACCBAACABBBAACABCBCACCAABCBCCBACBCBAABACA
112
FPHAJBKFKLLAIHENPDOIMLEFEDKFOLJDLAEEBOJMKEMCLAPLDNDAIHFMLPCJKLNF...

output:

15
45
0
0
5
0
50
1650
2255
8780
23365
42580
127740
290425
670250
1568755
3610180
8108515
19000400
34665300
100509020
226220730
510057265
1099335630
0
781179700
1529224115
1338910680
1510221160
1533484180

result:

ok 30 lines