题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4523
数据生成器:http://paste.ubuntu.com/23140079/
这个题,Trie树的做法很显然,可以持久,也可以不持久
但此题卡常QAQ
在BZOJ上过的不算,是男人就上Super OJ去交
我被逼着优化成了BZOJ上的Rank11才在SOJ上刚好卡过 (╯‵□′)╯︵┻━┻
#include<bits/stdc++.h> #define LL long long using namespace std; const int N = 1000000+9; const int M = 33000000; int Stack[N]; bool ip[40]; 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; } namespace Trie{ #define TRE Trie int tot=1,ch[M][2],cnt,root=1,end[M]; inline void modify(int len){ int w = root; for (int i=1;i<=len;i++) { int c = ip[i]; if (ch[w]) w = ch[w]; else w = ch[w] = ++tot; } end[w] = ++cnt; } inline int query(int l, int r){ int top = 0, w = root, t = 1; while (w) { if (end[w]) { while (top && Stack[top] > end[w]) top--; Stack[++top] = end[w]; } w = ch[w][ip[t]]; t++; } t = 0; for (int i=1;i<=top;i++) if (Stack[i] > r) break; else if (Stack[i] >= l) t++; return t; } }; inline void Get_IP(){ memset(ip,0,sizeof(ip)); for (int j=1,sta=9;j<=4;j++,sta+=8) { int TP = read(), i = 1; while (TP) ip[sta-i] = TP & 1, TP >>= 1, i++; } } int main(){ for (int k=read(),a,b;k;k--) { char c=getchar(); while (c != 'A' && c != 'Q') c=getchar(); if (c == 'A') { Get_IP(); TRE::modify(read()); } else { Get_IP(); a = read(); b = read(); printf("%d\n",TRE::query(a,b)); } } return 0; }
Very good blog.Much thanks again. Fantastic.
wow, awesome post.Really thank you! Cool.
This is a wonderful website. The site owner has carried out a superb job of putting it together, the info here is really insightful.
wow, awesome article post.Really looking forward to read more. Great.
Hey, thanks for the blog. Awesome.
Looking forward to reading more. Great post.Really looking forward to read more.
I loved your blog post.Much thanks again. Want more.
Looking forward to reading more. Great article post.Thanks Again. Cool.
Muchos Gracias for your article. Really Cool.
wow, awesome article.Really looking forward to read more. Great.
Thanks so much for the blog article.Much thanks again. Much obliged.
Thanks for sharing, this is a fantastic blog article.Thanks Again.
Thanks so much for the blog.Really thank you! Really Great.
Very neat blog post.Really looking forward to read more. Great.
Very informative blog. Awesome.
Enjoyed every bit of your post. Cool.
Wow, great blog article. Want more.
Thanks again for the post.Much thanks again. Keep writing.
A round of applause for your post.Much thanks again. Awesome.
Thanks again for the article post.Really looking forward to read more.
Thanks for the blog.Really looking forward to read more. Really Great.
Really enjoyed this article post. Awesome.
Major thankies for the post.Really looking forward to read more. Much obliged.
Wow, great article.Really looking forward to read more. Much obliged.
Thanks a lot for the blog article.Really looking forward to read more. Much obliged.
A round of applause for your post.Much thanks again. Cool.
Hey, thanks for the article.Really looking forward to read more. Fantastic.
Thanks for the blog article.Really looking forward to read more. Really Cool.
Thanks so much for the post.Really thank you! Really Great.
Looking forward to reading more. Great blog.Really looking forward to read more. Awesome.
I really liked your blog.Really looking forward to read more. Fantastic.
Major thankies for the article.Much thanks again. Really Cool.
This is one awesome blog article.Really looking forward to read more.
Muchos Gracias for your post.Thanks Again. Awesome.
I cannot thank you enough for the blog.Really thank you! Great.
Wow, great blog article.Much thanks again. Awesome.
Enjoyed every bit of your blog post.Really thank you! Keep writing.
This is one awesome blog.Really looking forward to read more. Fantastic.
Thanks so much for the blog. Awesome.
Major thanks for the article.Really thank you! Awesome.
I really liked your article post.Thanks Again. Awesome.
Thanks again for the blog post.Thanks Again. Cool.
Muchos Gracias for your article post.Really looking forward to read more. Awesome.
Thanks for sharing, this is a fantastic article post.Thanks Again. Will read on…
Major thanks for the post.Thanks Again. Really Cool.
Looking forward to reading more. Great article.Much thanks again. Will read on…
Fantastic blog article.Thanks Again. Really Great.
Very informative article post.Really thank you! Really Great.
Fantastic post.Much thanks again. Much obliged.
Your writing taste has been surprised me. Thank you, quite nice post.
Hey, thanks for the article post.Much thanks again. Really Great.
I appreciate you sharing this blog.Really looking forward to read more. Want more.
Thanks for sharing, this is a fantastic article.Really thank you! Fantastic.
wow, awesome blog. Want more.
Really informative article.Much thanks again. Much obliged.
Thanks again for the blog article.Thanks Again.
Very good article.Much thanks again.
Im obliged for the blog article.Thanks Again. Cool.
I loved your blog.Thanks Again. Awesome.
I appreciate you sharing this article. Keep writing.
Very good blog post.Really thank you! Will read on…
Enjoyed every bit of your blog post.Much thanks again. Really Great.
Thanks for sharing, this is a fantastic article post.Really looking forward to read more. Keep writing.
Thanks so much for the article post.Thanks Again. Keep writing.
A big thank you for your article.Really looking forward to read more. Keep writing.
wow, awesome blog post. Really Cool.
This is one awesome post.Thanks Again. Really Cool.
I really like and appreciate your article post.Thanks Again. Really Great.
Really informative blog post.Really thank you!
Looking forward to reading more. Great blog post.Really thank you! Fantastic.
Thanks-a-mundo for the post.Thanks Again. Awesome.
I loved your article. Really Cool.
A highly requested article, we’ll teach you how to find a replica Balenciaga Handbags dealer you can actually trust.
A big thank you for your post.Really looking forward to read more. Really Great.
I loved your blog article.Really thank you! Want more.
Thank you ever so for you article.Thanks Again. Keep writing.
Muchos Gracias for your blog article. Will read on…
A big thank you for your article post.Thanks Again. Will read on…
Thanks a lot for the blog post.Much thanks again. Much obliged.
Im obliged for the article post. Great.
Thanks for sharing, this is a fantastic article.Much thanks again. Cool.
Really informative post.Really thank you! Will read on…
Very neat blog.Really thank you! Cool.
Thank you for your blog post.Really looking forward to read more. Much obliged.
Thanks a lot for the blog post.Much thanks again. Want more.
Thanks so much for the blog article.Thanks Again. Really Great.
I cannot thank you enough for the blog post.Thanks Again. Fantastic.
Appreciate you sharing, great article.Thanks Again. Great.
Thanks so much for the blog article.Really looking forward to read more. Will read on…
Thanks again for the blog.Really looking forward to read more. Will read on…
As I web site possessor I believe the content matter here is rattling magnificent , appreciate it for your hard work. You should keep it up forever! Best of luck.
Awesome post.Thanks Again. Awesome.
Major thankies for the article post.Thanks Again. Great.
Great blog article.Much thanks again. Great.
Major thankies for the article post. Great.
Thanks so much for the blog article.Really thank you! Want more.
Muchos Gracias for your post.Thanks Again. Fantastic.
Thanks so much for the post.Really looking forward to read more. Will read on…
Major thankies for the article post.Really thank you! Fantastic.
Thanks a lot for the article.Much thanks again. Really Great.
Awesome blog post.Much thanks again. Great.
Major thanks for the blog article. Will read on…
Thanks again for the blog.Much thanks again. Really Great.
Im grateful for the article.Much thanks again. Want more.
This is one awesome post.Thanks Again. Keep writing.
Fantastic blog article.Thanks Again. Cool.
Hey, thanks for the blog.Really thank you! Really Great.
I really liked your blog post.Much thanks again. Awesome.
Thanks again for the blog post.Really thank you! Really Great.
I am so grateful for your post. Awesome.
I appreciate you sharing this article.Much thanks again. Keep writing.
Appreciate you sharing, great article post.Thanks Again. Fantastic.
I really like and appreciate your blog.Thanks Again. Awesome.
A round of applause for your blog post.Thanks Again. Much obliged.
Thank you ever so for you blog.Really thank you! Cool.
I think this is a real great blog post.Really thank you!
I really enjoy the post.Much thanks again. Will read on…
Muchos Gracias for your article.Really looking forward to read more. Great.
I really liked your blog article.Much thanks again. Cool.
Im grateful for the article post.Much thanks again. Want more.
Really informative blog.Much thanks again. Want more.
Very informative article post.Really looking forward to read more. Awesome.
Thank you for your blog.Really thank you! Cool.
This is one awesome blog.Really looking forward to read more. Awesome.
I value the blog article. Will read on…
I appreciate you sharing this blog article.Really looking forward to read more. Want more.
Im grateful for the blog.Much thanks again.
I loved your article. Really Cool.
Major thanks for the blog article. Want more.
Great article post.Really looking forward to read more. Want more.
I think this is a real great article.Really thank you! Will read on…
Say, you got a nice blog article.Thanks Again. Want more.
I am so grateful for your blog.Much thanks again. Really Great.
wow, awesome blog.Really looking forward to read more. Will read on…
I am so grateful for your blog.Much thanks again. Much obliged.
A round of applause for your article post.Really looking forward to read more. Want more.
Very informative blog article.Really thank you! Want more.
Great, thanks for sharing this article.Really thank you! Fantastic.
Thanks so much for the post.Really looking forward to read more. Awesome.
Looking forward to reading more. Great article. Awesome.
Say, you got a nice post.
Enjoyed every bit of your article post.Really thank you! Really Great.
wow, awesome article post.Really thank you! Awesome.
I think this is a real great blog article.Thanks Again. Great.
Thanks so much for the blog article. Awesome.
Enjoyed every bit of your blog.Really thank you! Much obliged.
This is one awesome article post. Want more.
Thank you for your article. Will read on…
A round of applause for your blog.Much thanks again. Really Cool.
Really appreciate you sharing this post.Much thanks again. Really Great.
A big thank you for your article.Much thanks again. Great.
Really enjoyed this blog.Thanks Again. Keep writing.
I value the post.Much thanks again.
I appreciate you sharing this blog article.Much thanks again. Fantastic.
Muchos Gracias for your blog article.Really looking forward to read more.
Im obliged for the blog post.Really looking forward to read more. Will read on…
Im obliged for the blog.Really thank you! Cool.
Enjoyed every bit of your blog post.Thanks Again. Great.
Thanks for sharing, this is a fantastic blog post.Really looking forward to read more. Great.
Looking forward to reading more. Great blog.Really thank you! Will read on…
Major thankies for the post.Thanks Again. Cool.
Very good blog post.Thanks Again. Really Cool.
Thanks for the blog post.Much thanks again. Cool.
Major thankies for the article.Really looking forward to read more.
Im thankful for the blog article. Keep writing.
Thank you ever so for you blog article. Will read on…
Fantastic article post.Much thanks again. Much obliged.
Enjoyed every bit of your blog.Much thanks again. Awesome.
Say, you got a nice blog post.Really looking forward to read more. Really Great.
Really enjoyed this blog article.Really looking forward to read more. Awesome.
I really liked your blog article.Thanks Again. Much obliged.
I really liked your blog article.Really thank you! Fantastic.
Muchos Gracias for your blog post.Really thank you! Really Great.
I really enjoy the post.Really thank you! Keep writing.
Enjoyed every bit of your post.Really looking forward to read more. Keep writing.
Really informative article post.Really thank you! Really Great.
Thanks so much for the blog.Much thanks again. Fantastic.
Very neat blog post.Really looking forward to read more. Will read on…
Major thanks for the post.Really looking forward to read more. Cool.
Im obliged for the blog.Thanks Again. Will read on…
Muchos Gracias for your blog.Thanks Again. Keep writing.
I really like and appreciate your blog article. Great.
Thank you ever so for you blog post.Thanks Again. Cool.
Enjoyed every bit of your blog article. Keep writing.
Say, you got a nice blog post.Thanks Again. Want more.
Hey, thanks for the article post.Much thanks again. Keep writing.
Very neat blog article.Thanks Again. Will read on…
Thanks-a-mundo for the blog post.Really thank you!
Muchos Gracias for your blog.Really thank you! Will read on…
Looking forward to reading more. Great blog article.Really thank you! Fantastic.
Im thankful for the article post.Really thank you! Cool.
Im thankful for the blog.Much thanks again. Cool.
Really enjoyed this blog article.Really thank you! Really Great.
I just like the helpful info you supply for your articles. I’ll bookmark your blog and take a look at again right here frequently. I am relatively certain I will be told lots of new stuff proper right here! Good luck for the next!
Im thankful for the post.Really looking forward to read more. Much obliged.
Great article.Really thank you! Much obliged.
Im grateful for the article post.Really looking forward to read more. Keep writing.
Thank you ever so for you blog.Really thank you! Will read on…
I really enjoy the article post.Thanks Again. Great.
Fantastic article.Really thank you! Awesome.
I really enjoy the article.Thanks Again. Awesome.
Very informative post.Really looking forward to read more. Much obliged.
I really liked your article post.Really thank you!
I really liked your blog post.Really looking forward to read more. Really Cool.
I truly appreciate this blog post.Much thanks again. Fantastic.
Im grateful for the blog article.Really thank you! Awesome.
I appreciate you sharing this article post.Really thank you! Great.
A big thank you for your article.Really looking forward to read more. Cool.
Thanks-a-mundo for the blog article.Really looking forward to read more. Great.
Thanks-a-mundo for the blog article. Cool.
Thanks so much for the blog.Really thank you! Keep writing.
Magnificent beat ! I wish to apprentice while you amend your site, how can i subscribe for a blog site? The account aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast provided bright clear idea|
This website was… how do I say it? Relevant!! Finally I have found something which helped me. Thanks!|
Im grateful for the article.Really looking forward to read more. Want more.
I think this is a real great article post.Really looking forward to read more. Awesome.
I am actually pleased to read this web site posts which contains lots of helpful data, thanks for providing these kinds of information.|
I loved your article.Much thanks again. Fantastic.
Appreciate you sharing, great blog.Thanks Again. Cool.
I am really enjoying the theme/design of your web site. Do you ever run into any internet browser compatibility problems? A handful of my blog visitors have complained about my site not operating correctly in Explorer but looks great in Firefox. Do you have any tips to help fix this issue?|
Enjoyed every bit of your post. Cool.
I appreciate you sharing this article. Really Cool.
Very informative article.Really thank you! Much obliged.
Very informative blog.Really looking forward to read more. Want more.
Great post. I was checking continuously this blog and I am impressed! Very helpful info particularly the last part 🙂 I care for such information much. I was looking for this certain info for a long time. Thank you and good luck.|
Great, thanks for sharing this article post.Really thank you! Great.
Major thankies for the article. Really Great.
I am in fact thankful to the owner of this web page who has shared this fantastic post at at this time.|
Very neat article.Much thanks again. Much obliged.
I think this is a real great blog article.Really thank you! Awesome.
Thanks for some other magnificent article. Where else could anyone get that kind of info in such an ideal means of writing? I have a presentation next week, and I’m on the search for such info.|
Thanks for sharing, this is a fantastic blog article. Keep writing.
Really informative blog. Great.
Hi I am so grateful I found your website, I really found you by error, while I was searching on Bing for something else, Nonetheless I am here now and would just like to say thank you for a remarkable post and a all round interesting blog (I also love the theme/design), I don’t have time to browse it all at the minute but I have book-marked it and also added your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the excellent b.|
Appreciate you sharing, great blog. Want more.
Say, you got a nice blog post.Really looking forward to read more. Keep writing.
Im obliged for the article post.Much thanks again. Really Cool.
Hello, this weekend is good designed for me, as this moment i am reading this enormous educational paragraph here at my residence.|
I’m not sure where you’re getting your info, but good topic. I needs to spend some time learning much more or understanding more. Thanks for fantastic information I was looking for this information for my mission.|
Hey! I know this is kind of off topic but I was wondering which blog platform are you using for this site? I’m getting sick and tired of WordPress because I’ve had issues with hackers and I’m looking at alternatives for another platform. I would be awesome if you could point me in the direction of a good platform.|
I truly appreciate this article post.Thanks Again. Awesome.
Thanks for the blog article.Really looking forward to read more. Much obliged.
Really appreciate you sharing this blog article.Really looking forward to read more. Much obliged.
I appreciate you sharing this article post.Thanks Again. Much obliged.
Enjoyed every bit of your article.Really looking forward to read more. Awesome.
I really liked your blog.Much thanks again. Cool.
Yesterday, while I was at work, my cousin stole my iPad and tested to see if it can survive a thirty foot drop, just so she can be a youtube sensation. My iPad is now broken and she has 83 views. I know this is totally off topic but I had to share it with someone!|
Very good article post.Much thanks again. Really Great.
Major thankies for the blog post.Thanks Again. Keep writing.
Thank you for your post.Thanks Again.
Im obliged for the blog post.Really thank you! Fantastic.
Woah! I’m really enjoying the template/theme of this blog. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say that you’ve done a excellent job with this. Additionally, the blog loads extremely fast for me on Chrome. Outstanding Blog!|
I’m excited to uncover this website. I want to to thank you for your time for this particularly fantastic read!! I definitely really liked every part of it and i also have you book-marked to check out new stuff on your site.|