题目传送门:http://codeforces.com/contest/703/problem/D
中文题面:http://www.cnblogs.com/zqy123/p/5746481.html
这题,第一眼看到就感觉是莫队
然后算一算复杂度感觉能卡过,于是死坑莫队,遂卒
然后看题解,突然想起来以前做过这么一道题,还有分块的解法
不过最简单的做法,可以记录pre[],然后维护区间的unique之后的值
离线的话,一维BIT即可,不离线的话,可以上函数式线段树
#include<algorithm> #include<iostream> #include<cstring> #include<cstdlib> #include<cstdio> #include<cmath> #include<map> #define LL long long #define abs(x) ((x)>0?(x):-(x)) using namespace std; const int N = 1000000+9; int arr[N],n,m,sum[N],vout[N]; struct Query{ int l,r,num; inline bool operator < (const Query &B) const { return r < B.r; } }q[N]; map<int,int> pre; namespace Fenwick_Tree{ #define BIT Fenwick_Tree #define lowbit(x) ((x)&-(x)) int v[N]; inline void modify(int i) { int tmp = pre[arr[i]]; pre[arr[i]] = i; if (tmp) for (int j=tmp;j<=n;j+=lowbit(j)) v[j] ^= arr[i]; for (int j=i;j<=n;j+=lowbit(j)) v[j] ^= arr[i]; } inline int query(int l, int r) { int ret = 0; l--; for (;r;r-=lowbit(r)) ret ^= v[r]; for (;l;l-=lowbit(l)) ret ^= v[l]; return ret; } }; inline int read(){ char c=getchar(); int ret=0,f=1; while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();} while (c<='9'&&c>='0') ret=ret*10+c-'0',c=getchar(); return ret*f; } int main(){ n = read(); for (int i=1;i<=n;i++) arr[i] = read(); m = read(); for (int i=1;i<=m;i++) q[i].l=read(), q[i].r=read(), q[i].num = i; sort(q+1,q+1+m); for (int i=1,cur=1;i<=n;i++) { sum[i] = sum[i-1] ^ arr[i]; BIT::modify(i); for (;cur <= m && q[cur].r == i;cur++) vout[q[cur].num] = sum[i]^sum[q[cur].l-1]^BIT::query(q[cur].l,q[cur].r); } for (int i=1;i<=m;i++) printf("%d\n",vout[i]); return 0; }
把BZOJ上那题翻出来了,分块的做法让我们召唤黄学长:http://hzwer.com/3663.html
Thanks a lot for the blog post. Really Cool.
Im grateful for the blog.Thanks Again. Awesome.
I really like and appreciate your blog article. Much obliged.
Muchos Gracias for your article.Thanks Again. Want more.
I appreciate you sharing this article.Thanks Again. Fantastic.
Really informative blog post.
I value the blog article.Much thanks again. Great.
Major thanks for the blog article.Much thanks again. Much obliged.
Thanks for the blog article.Much thanks again. Really Cool.
Really appreciate you sharing this blog.Really looking forward to read more. Really Great.
Major thanks for the blog post.Really thank you! Awesome.
I think this is a real great blog.Much thanks again.
Appreciate you sharing, great blog post. Much obliged.
Thanks so much for the blog post.Much thanks again. Want more.
Im grateful for the blog article.Much thanks again.
Hey, thanks for the blog post.Thanks Again. Keep writing.
Very good blog post.Really looking forward to read more. Great.
Thanks-a-mundo for the blog. Really Cool.
Wow, great blog.Really looking forward to read more. Want more.
Really appreciate you sharing this article.Really thank you! Want more.
A big thank you for your blog.Much thanks again.
Great article.Much thanks again. Much obliged.
I really like and appreciate your blog.
Im thankful for the post.Really thank you! Fantastic.
Im grateful for the article.Thanks Again. Keep writing.
Thanks a lot for the blog post.Thanks Again.
Wow, great article. Really Great.
Major thanks for the article.Really thank you! Keep writing.
Really appreciate you sharing this blog. Keep writing.
A big thank you for your blog post.Much thanks again. Really Great.
Very neat article post.Much thanks again. Awesome.
Enjoyed every bit of your article post.Much thanks again. Great.
Very neat post. Keep writing.
Really appreciate you sharing this blog post.Much thanks again. Much obliged.
A round of applause for your post.Thanks Again. Cool.
Thank you for your blog.Much thanks again. Cool.
Thank you ever so for you article. Fantastic.
I am so grateful for your blog article.Really looking forward to read more. Really Great.
Thanks for sharing, this is a fantastic article post.Really looking forward to read more. Keep writing.
Im obliged for the blog.Much thanks again. Fantastic.
I think this is a real great blog.Really thank you! Great.
wow, awesome post.
A round of applause for your article.Thanks Again. Cool.
Great blog.Thanks Again. Much obliged.
I think this is a real great article. Will read on…
Thanks for sharing, this is a fantastic blog.Thanks Again. Much obliged.
Your writing taste has been surprised me. Thank you, quite nice post.
This is one awesome post. Cool.
I truly appreciate this post. I have been looking everywhere for this
Very informative post.Thanks Again. Much obliged.
Thanks again for the blog.Really thank you! Keep writing.
Appreciate you sharing, great article. Fantastic.
Awesome blog post.Really thank you! Want more.
Thanks a lot for the article post.Thanks Again. Cool.
Thanks a lot for the post.Much thanks again. Want more.
Thanks a lot for the article.Thanks Again.
I value the blog article. Cool.
Thank you for your blog post. Really Great.
A round of applause for your blog post.Much thanks again.
Hey, thanks for the blog post.Much thanks again. Will read on…
Great post.Much thanks again. Awesome.
I value the post.Thanks Again.
Major thanks for the article.Really thank you! Awesome.
Thanks for the article post.Really looking forward to read more. Awesome.
Say, you got a nice blog post.Thanks Again. Awesome.
Im obliged for the post. Really Great.
Thanks for sharing, this is a fantastic article post. Keep writing.
I loved your blog post.Really thank you! Really Cool.
Thank you for your article.Much thanks again. Great.
This is one awesome article post.Really looking forward to read more. Keep writing.
I am so grateful for your article post.Thanks Again. Really Great.
Really informative article.Thanks Again. Keep writing.
I really enjoy the blog article.Much thanks again. Really Great.
I am so grateful for your blog.Thanks Again. Much obliged.
Im obliged for the blog post.Really thank you! Want more.
I loved your blog article.Thanks Again. Great.
Thanks for sharing, this is a fantastic blog article.Thanks Again. Will read on…
Really enjoyed this article post.Really thank you! Really Cool.
I really liked your article.Really looking forward to read more.
Thanks so much for the post.Thanks Again. Much obliged.
I truly appreciate this post.Really thank you! Will read on…
Thank you for your post.Much thanks again. Awesome.
Thanks for the post.Thanks Again. Much obliged.
Appreciate you sharing, great post. Fantastic.
Really appreciate you sharing this blog article.Much thanks again.
Enjoyed every bit of your blog article.Really thank you! Want more.
Really appreciate you sharing this article.Really looking forward to read more. Cool.
Im obliged for the article post.Really thank you! Will read on…
I really like and appreciate your article post. Keep writing.
Excellent read, I just passed this onto a colleague who was doing some research on that. And he just bought me lunch as I found it for him smile Therefore let me rephrase that: Thank you for lunch! “We know what happens to people who stay in the middle of the road. They get run over.” by Ambrose Gwinett Bierce.
I appreciate you sharing this blog.Really looking forward to read more. Much obliged.
Enjoyed every bit of your blog article.Really thank you! Great.
I truly appreciate this blog article.Really looking forward to read more. Really Cool.
Great, thanks for sharing this blog article.Thanks Again. Fantastic.
Thank you ever so for you blog post.Really looking forward to read more. Keep writing.
Really enjoyed this article post. Cool.
Thank you for your post.Much thanks again. Really Great.
Really appreciate you sharing this article post.Thanks Again.
Great blog article.Thanks Again. Really Great.
I really enjoy the post.Really looking forward to read more. Really Cool.
I really enjoy the article post.Thanks Again. Really Cool.
I appreciate you sharing this blog.Much thanks again. Keep writing.
Very neat blog.Really looking forward to read more. Want more.
I am so grateful for your article.Really thank you! Will read on…
Wow, great blog article.Really looking forward to read more. Really Cool.
I think this is a real great article post.Really thank you! Cool.
Fantastic blog post.Really thank you! Fantastic.
Very informative article post.Thanks Again.
Thanks a lot for the blog article.Much thanks again. Awesome.
Say, you got a nice article.Really looking forward to read more. Keep writing.
Thanks again for the blog post. Great.
Thanks a lot for the article post.Really thank you!
Great, thanks for sharing this post.Really thank you! Want more.
Im obliged for the blog article.Much thanks again. Keep writing.
Great blog article.Thanks Again. Keep writing.
Really appreciate you sharing this blog post.Much thanks again.
I appreciate you sharing this post. Awesome.
Really informative blog article.Really looking forward to read more. Much obliged.
A big thank you for your blog article. Much obliged.
Appreciate you sharing, great article. Fantastic.
Thanks again for the blog post.Thanks Again.
I value the blog post.Thanks Again. Much obliged.
I truly appreciate this post.Thanks Again. Great.
Thank you for your post.Really thank you! Cool.
I really liked your blog article.Thanks Again. Fantastic.
Muchos Gracias for your post.Really looking forward to read more. Really Great.
A big thank you for your blog.
Say, you got a nice article post.Much thanks again. Cool.
Thanks again for the blog.Really thank you! Much obliged.
I think this is a real great blog article. Great.
Hey, thanks for the article.Really thank you! Fantastic.
Very neat blog post.Really looking forward to read more. Will read on…
Thanks for the post.Much thanks again. Great.
Muchos Gracias for your blog. Awesome.
A big thank you for your article post.Thanks Again. Fantastic.
Thanks for the article.Much thanks again. Really Cool.
A big thank you for your blog post.Much thanks again.
Thank you for your blog article.Really thank you! Keep writing.
Fantastic blog article.Thanks Again. Really Cool.
A round of applause for your blog article.Really thank you! Keep writing.
Thank you for your article.Thanks Again.
Enjoyed every bit of your post.Really looking forward to read more. Really Cool.
Thanks so much for the post.Thanks Again.
Im obliged for the blog post.Thanks Again.
Appreciate you sharing, great blog article.Really thank you! Really Great.
This is one awesome article.Much thanks again. Keep writing.
Thanks a lot for the post.Much thanks again. Will read on…
I value the post.Much thanks again. Great.
Fantastic article post. Really Cool.
This is one awesome article post.Really looking forward to read more. Really Cool.
A big thank you for your article.Thanks Again. Great.
I really like and appreciate your blog article.Thanks Again. Fantastic.
Very informative blog.Much thanks again. Great.
Really informative blog.
I really enjoy the post.Really looking forward to read more. Great.
Thanks again for the blog post.Really thank you! Keep writing.
I am so grateful for your blog. Really Great.
Major thanks for the blog post. Want more.
Im obliged for the blog article.Really thank you! Cool.
I really liked your article.Much thanks again. Keep writing.
I appreciate you sharing this post. Really Cool.
Great article post.Thanks Again. Great.
Very neat blog article.Thanks Again. Fantastic.
Hey, thanks for the article.Thanks Again. Great.
I truly appreciate this blog post.Really thank you! Really Great.
Great article. Cool.
Awesome post.Really thank you! Want more.
I really liked your blog post.Much thanks again. Much obliged.
I really like and appreciate your blog. Keep writing.
Muchos Gracias for your blog post.Really looking forward to read more.
Really enjoyed this post.Really thank you! Will read on…
Really informative blog article.Really looking forward to read more. Will read on…
Looking forward to reading more. Great post.
I cannot thank you enough for the blog article.Thanks Again. Keep writing.
Major thankies for the article post.Much thanks again. Cool.
Very neat article post.Really looking forward to read more. Fantastic.
Thanks-a-mundo for the blog article.
Really appreciate you sharing this article post.Thanks Again. Awesome.
I appreciate you sharing this blog post.Thanks Again. Cool.
I really like and appreciate your blog post.Much thanks again. Will read on…
Really informative blog post. Will read on…
Appreciate you sharing, great blog article. Cool.
Major thankies for the post.Much thanks again. Much obliged.
Very informative blog.Thanks Again. Much obliged.
I think this is a real great blog article.Really looking forward to read more. Cool.
Fantastic article.Thanks Again. Awesome.
Thanks a lot for the blog article.Really looking forward to read more. Really Great.
Im thankful for the post.Much thanks again. Much obliged.
Wow, great blog article.Much thanks again. Much obliged.
wow, awesome blog article.Really looking forward to read more. Great.
I really like and appreciate your article.Really looking forward to read more. Really Cool.
Im grateful for the blog post.Thanks Again. Keep writing.
I was curious if you ever thought of changing the page layout of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or two pictures. Maybe you could space it out better?
Thanks-a-mundo for the blog article.Really looking forward to read more. Much obliged.
I don’t even understand how I stopped up rignt here, howewver I assumed thispublish used to be good. I don’t recognise who you’re butcertaily you are going to a well-known blogger iif you aren’t already.Cheers!
I really like and appreciate your article.Really thank you! Cool.
The Zune concentrates on being a Portable Media Player. Not a web browser. Not a game machine. Maybe in the future it’ll do even better in those areas, but for now it’s a fantastic way to organize and listen to your music and videos, and is without peer in that regard. The iPod’s strengths are its web browsing and apps. If those sound more compelling, perhaps it is your best choice.
Hey there. I discovered your web site by way of Google while looking for a related subject, your website got here up. It seems great. I have bookmarked it in my google bookmarks to visit then.
I loved as much as you will receive carried out right here. The sketch is tasteful, your authored material stylish. nonetheless, you command get bought an nervousness over that you wish be delivering the following. unwell unquestionably come further formerly again as exactly the same nearly a lot often inside case you shield this increase.
Hey there! I’ve been following your website for a long timenow and finally got the bravery to go ahead and giveyou a shout out from Huffman Tx! Just wanted to tell youkeep up the great work!
Thanks a lot for the post.Really looking forward to read more. Fantastic.
Major thanks for the article post.Thanks Again. Will read on…
Fantastic blog.Much thanks again. Great.
Thanks so much for the post. Really Great.
Really appreciate you sharing this post.Really looking forward to read more. Fantastic.
I really like and appreciate your blog. Great.
Major thankies for the article post.Thanks Again. Fantastic.
Fantastic blog.Thanks Again. Keep writing.
I would like to thnkx for the efforts you have put in writing this blog. I’m hoping the same high-grade web site post from you in the upcoming also. In fact your creative writing abilities has inspired me to get my own website now. Really the blogging is spreading its wings rapidly. Your write up is a good example of it.
Enjoyed every bit of your post. Want more.
I really like and appreciate your blog.Much thanks again.
This is one awesome blog article. Fantastic.
Im obliged for the blog post.Much thanks again. Really Great.
Thanks for the blog post.Much thanks again. Really Cool.
A round of applause for your blog.Thanks Again. Fantastic.
Thanks-a-mundo for the article.Really thank you! Awesome.
That is a very good tip especially to those fresh to the blogosphere. Short but very accurate info… Thanks for sharing this one. A must read article!|
I cannot thank you enough for the post.Much thanks again. Much obliged.
Hurrah! After all I got a webpage from where I can truly get helpful facts regarding my study and knowledge.|
I really liked your post.Much thanks again. Fantastic.
It is appropriate time to make some plans for the future and it’s time to be happy. I have read this post and if I could I desire to suggest you few interesting things or suggestions. Maybe you could write next articles referring to this article. I wish to read more things about it!|
Im grateful for the blog.Much thanks again. Awesome.
Thanks again for the article.Thanks Again. Really Cool.
Nice post. I was checking constantly this blog and I am impressed! Extremely helpful information specifically the last part 🙂 I care for such information a lot. I was looking for this particular info for a very long time. Thank you and good luck.|
Thanks for sharing, this is a fantastic article post. Will read on…
Appreciate you sharing, great article.Thanks Again. Fantastic.
Im grateful for the article.Really looking forward to read more. Really Great.
Fantastic article.Much thanks again. Will read on…
Heya! I’m at work surfing around your blog from my new iphone! Just wanted to say I love reading your blog and look forward to all your posts! Carry on the fantastic work!|
Awesome article.Much thanks again. Really Cool.
Very neat article.Really looking forward to read more. Want more.
I relish, lead to I found just what I was looking for. You have ended my 4 day lengthy hunt! God Bless you man. Have a great day. Bye|
Looking forward to reading more. Great blog article.Thanks Again. Really Great.
I really like and appreciate your blog article.Really looking forward to read more. Cool.
Really appreciate you sharing this blog.Really looking forward to read more. Fantastic.
Im obliged for the post.Much thanks again. Keep writing.
I’ve been browsing online greater than three hours as of late, but I by no means found any fascinating article like yours. It is beautiful price enough for me. In my opinion, if all site owners and bloggers made just right content as you probably did, the internet will probably be a lot more helpful than ever before.|
A fascinating discussion is worth comment. There’s no doubt that that you should publish more about this subject, it may not be a taboo subject but generally folks don’t discuss these subjects. To the next! Best wishes!!|
Thanks again for the article.Really looking forward to read more. Awesome.
Thanks so much for the blog.Much thanks again. Fantastic.
I appreciate you sharing this article.Really thank you! Cool.
I think the admin of this web site is genuinely working hard for his web site, for the reason that here every stuff is quality based material.|
Hello to all, how is everything, I think every one is getting more from this site, and your views are pleasant for new users.|
very good article
I don’t even know how I ended up here, but I thought this post was great. I don’t know who you are but certainly you’re going to a famous blogger if you are not already 😉 Cheers!|
Really enjoyed this blog article. Awesome.
Excellent post. I’m dealing with some of these issues as well..|
wonderful post, very informative. I’m wondering why the other specialists of this sector don’t understand this. You should continue your writing. I’m confident, you have a huge readers’ base already!|
A round of applause for your blog article. Awesome.
Thank you for your article post.Much thanks again. Cool.
Appreciate you sharing, great article. Want more.
Hi there! Do you know if they make any plugins to protect against hackers? I’m kinda paranoid about losing everything I’ve worked hard on. Any suggestions?|
I am in fact thankful to the owner of this website who has shared this great post at at this time.|
Major thanks for the article post.Thanks Again. Cool.
I value the article.Really thank you! Awesome.
Muchos Gracias for your post.Thanks Again.
Thanks a lot for the blog.Much thanks again. Want more.
Hello everyone, it’s my first go to see at this website, and paragraph is genuinely fruitful for me, keep up posting these types of articles.|
Thank you ever so for you post.
I really enjoy the blog.Really looking forward to read more.
This is really interesting, You are a very skilled blogger. I have joined your rss feed and look forward to seeking more of your great post. Also, I have shared your web site in my social networks!|
I don’t even know how I stopped up right here, however I thought this submit used to be great. I do not know who you are but definitely you’re going to a well-known blogger should you are not already. Cheers!|
I’m really enjoying the design and layout of your site. It’s a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a developer to create your theme? Excellent work!|