莫队蒟蒻求调 莫名WA on #3

CF940F Machine Learning

```cpp int l=0,r=0,h=0; for(int i=1;i<=tot_cnt;i++) { while(r<q[i].r)add(col[++r]); while(r>q[i].r)remove(col[r--]); while(l>q[i].l)add(col[--l]); while(l<q[i].l)remove(col[l++]); while(h<q[i].his)update(++h,l,r); while(h>q[i].his)update(h--,l,r); ans[q[i].num]=mex(); } ``` 改为 ```cpp int l=1,r=1,h=0; count1[col[l]]=1; count2[1]=1; for(int i=1;i<=tot_cnt;i++) { while(r<q[i].r)add(col[++r]); while(r>q[i].r)remove(col[r--]); while(l>q[i].l)add(col[--l]); while(l<q[i].l)remove(col[l++]); while(h<q[i].his)update(++h,l,r); while(h>q[i].his)update(h--,l,r); ans[q[i].num]=mex(); } ``` 依然是错的
by zhenji_190127 @ 2021-06-21 10:04:58


移动左右端点时应该先 add 后 remove,不然出现次数可能减到负数。
by watermoon @ 2021-06-21 11:56:06


@[AThousandMoon](/user/68148) 已经改过重提交,但好像不止有这个问题欸 在第三个点的第四个输出比答案大一
by zhenji_190127 @ 2021-06-21 13:55:20


貌似是离散化的原因? 把map离散化改成lower_bound来离散化就通过了 没有道理啊啊啊啊啊啊啊 map至少是TLE吧 为什么会WA勒 奇奇怪怪
by zhenji_190127 @ 2021-06-21 14:24:33


@[AThousandMoon](/user/68148) 谢谢大佬,已经解决疑问了
by zhenji_190127 @ 2021-06-21 14:48:33


|