P2709 小B的询问
思路
简单的莫队,开个桶记录下颜色出现次数即可
代码
#include
#include
#include
#include
using namespace std;
int sum,color[200200],L,R,n,m,a[200200],belong[200200],sz,ans[200200],b[200200],tx;
struct Query{
int l,r,id;
bool operator < (const Query &b) const{
return belong[l]==belong[b.l]?rQ[i].l)
moveL(-1);
while(RQ[i].r)
moveR(-1);
ans[Q[i].id]=sum;
}
for(int i=1;i<=m;i++){
printf("%d\n",ans[i]);
}
return 0;
}