或许是因为我最近学了自动RE机的原因吗?
哪儿RE了呀qwq,求dalao帮忙康康qwq
#include<algorithm>
#include<cstdio>
#include<cmath>
const int M=50005;
int n,m,num[M],clo[M];
long long cur,ans1[M],ans2[M];
struct Sec{
int L,R,p,id;
friend inline bool operator<(const Sec&a,const Sec&b){
return a.p==b.p?a.R<b.R:a.L<b.L;
}
}q[M];
inline void Add(const int&id){
cur+=num[id]++<<1|1;
}
inline void Del(const int&id){
cur-=--num[id]<<1|1;
}
signed main(){
int i,L=1,R=0,block;
long long u;
scanf("%d%d",&n,&m);
block=n/sqrt(m*2/3);
for(i=1;i<=n;++i)scanf("%d",clo+i);
for(i=1;i<=m;++i){
scanf("%d%d",&q[i].L,&q[i].R);
q[i].id=i;q[i].p=q[i].L/block;
}
std::sort(q+1,q+m+1);
for(i=1;i<=m;++i){
int&QL=q[i].L,&QR=q[i].R;
while(L<QL)Del(clo[L++]);
while(L>QL)Add(clo[--L]);
while(R<QR)Add(clo[++R]);
while(R>QR)Del(clo[R--]);
ans1[q[i].id]=cur-(R-L+1);ans2[q[i].id]=(R-L)*(R-L+1);
}
for(i=1;i<=m;++i){
if(q[i].L==q[i].R)printf("0/1\n");
else{
u=std::__gcd(ans1[i],ans2[i]);
printf("%lld/%lld\n",ans1[i]/u,ans2[i]/u);
}
}
}