相关链接
题目传送门:http://arc068.contest.atcoder.jp/tasks/arc068_c
数据生成器:http://paste.ubuntu.com/23948002/
官方题解:https://arc068.contest.atcoder.jp/editorial
解题报告
设一个间隔$d$,一种物品的覆盖区间长度为$L$
若 $L \ge d$ 则一定能取,否则只会被遍历到一次
于是我们就从小到达枚举$d$,同时维护$L$,把$L < d$的扔到$BIT$里就可以啦!
复杂度: $O(n{log^2}n)$,不过因为$BIT$的常数关系,所以跑得飞快
Code
#include<bits/stdc++.h> #define LL long long using namespace std; const int N = 300000+9; int n,m; struct Event{ int l,r,len; inline Event() {} inline Event(int _l, int _r) {l = _l; r = _r; len = r - l + 1;} inline bool operator < (const Event &B) const {return len < B.len;} }e[N]; class Fenwick_Tree{ int cnt[N]; public: inline void modify(int l, int r) { for (int i=l-1;i;i-=lowbit(i)) cnt[i]--; for (int i=r;i;i-=lowbit(i)) cnt[i]++; } inline int query(int p) { int ret = 0; for (int i=p;i<=m;i+=lowbit(i)) ret += cnt[i]; return ret; } private: inline int lowbit(int x) { return x & -x; } }BIT; inline int read() { char c=getchar(); int f=1,ret=0; 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(); m = read(); for (int i=1,l,r;i<=n;i++) { l = read(); r = read(); e[i] = Event(l, r); } sort(e+1, e+1+n); for (int d=1,p=1,sta=n;d<=m;d++) { for (;p<=n&&e[p].len==d-1;p++) { --sta; BIT.modify(e[p].l, e[p].r); } int vout = 0; for (int i=d;i<=m;i+=d) vout += BIT.query(i); printf("%d\n",vout+sta); } return 0; }
Thanks for the article.Thanks Again. Great.
Great, thanks for sharing this blog article.Really looking forward to read more. Keep writing.
Thanks again for the blog.Much thanks again. Cool.
Im grateful for the blog post.Much thanks again. Awesome.
This is one awesome article. Really Great.
Thanks for sharing, this is a fantastic article.Thanks Again. Cool.
I truly appreciate this article.Really looking forward to read more. Awesome.
This is one awesome blog.Really looking forward to read more. Much obliged.
Thanks again for the article.
Thank you for your post.Really looking forward to read more. Really Cool.
Awesome blog post.Really looking forward to read more. Really Great.
This is one awesome blog article.Really looking forward to read more. Great.
Very neat article post.Really thank you! Keep writing.
Awesome blog post.Much thanks again.
Looking forward to reading more. Great blog.Thanks Again. Will read on…
I think this is a real great blog.Really thank you! Want more.
I loved as much as you will receive carried out right here.
The sketch is attractive, 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 since exactly the same nearly very often inside case you shield this
hike.
Hello my loved one! I want to say that this article is amazing, nice written and include approximately
all important infos. I’d like to peer more posts
like this .
Thanks-a-mundo for the article.Really thank you! Great.
Fantastic blog article.Really looking forward to read more. Really Great.
I truly appreciate this blog post.Really looking forward to read more. Really Great.
wow, awesome blog article. Awesome.
Hi there, just became aware of your blog through Google, and
found that it’s really informative. I am going to watch out for brussels.
I will be grateful if you continue this
in future. Lots of people will be benefited
from your writing. Cheers!
Great, thanks for sharing this post.Much thanks again. Great.
This is one awesome blog.Much thanks again. Keep writing.
It’s very effortless to find out any topic on net
as compared to books, as I found this article at this
web site.
Thanks for the post. Keep writing.
Appreciate you sharing, great blog.Thanks Again. Really Cool.
I think this is a real great post. Really Cool.
This is very interesting, You’re a very skilled blogger.
I’ve joined your rss feed and look forward to seeking more of your magnificent post.
Also, I’ve shared your site in my social networks!
Major thanks for the blog post.Really thank you! Want more.
I am so grateful for your post.Much thanks again. Fantastic.
Great, thanks for sharing this blog article.Really looking forward to read more. Want more.
Appreciate you sharing, great post.Thanks Again. Want more.
Great, thanks for sharing this article.Really looking forward to read more. Awesome.
A round of applause for your blog. Will read on…
Helpful information. Fortunate me I found your site unintentionally, and I am surprised why this accident didn’t came about in advance!
I bookmarked it.
Muchos Gracias for your article post.Really looking forward to read more. Want more.
A round of applause for your article.Really thank you! Keep writing.
Awesome blog post. Much obliged.
Really informative blog article.Really looking forward to read more. Want more.
Thanks for your marvelous posting! I actually enjoyed reading it,
you’re a great author. I will always bookmark your blog and will come back
from now on. I want to encourage continue your great writing, have a nice
weekend!
Definitely believe that which you stated. Your favorite justification appeared to
be on the web the easiest thing to be aware of. I say to you,
I definitely get annoyed while people think about worries that they just don’t know about.
You managed to hit the nail upon the top as well as defined out the whole thing without having side effect ,
people could take a signal. Will probably be back to get more.
Thanks
It’s going to be end of mine day, but before ending I am reading this fantastic article to increase
my know-how.
WOW just what I was searching for. Came here by searching for quest bars cheap
Thanks for the blog.Thanks Again. Great.
hello!,I like your writing so a lot! percentage we keep in touch
extra about your article on AOL? I require an expert in this area
to resolve my problem. May be that is you!
Having a look forward to peer you.
I appreciate you sharing this blog post.Really thank you! Awesome.
Greetings! I know this is kinda off topic nevertheless
I’d figured I’d ask. Would you be interested in trading
links or maybe guest writing a blog post or vice-versa?
My blog discusses a lot of the same subjects as yours and I
believe we could greatly benefit from each other. If you’re interested feel free to
send me an e-mail. I look forward to hearing from you!
Fantastic blog by the way!
Really appreciate you sharing this blog.Much thanks again. Keep writing.
Major thanks for the blog article.Really looking forward to read more.
Hi there, I discovered your web site by the use of Google while searching for a comparable topic, your web site came up, it
appears to be like good. I have bookmarked it in my google bookmarks.
Hello there, simply become alert to your blog thru Google, and located that it
is truly informative. I am gonna watch out
for brussels. I’ll appreciate should you continue this in future.
Many people will probably be benefited from your writing.
Cheers!
I couldn’t resist commenting
Fantastic post. Cool.
Major thankies for the post. Cool.
Oh my goodness! Impressive article dude! Many thanks, However I am going through problems with your RSS.
I don’t know why I cannot join it. Is there anybody else having the same RSS issues?
Anyone who knows the solution will you kindly respond?
Thanx!!
Thanks-a-mundo for the blog article.Really thank you!
Thanks-a-mundo for the blog article.Really looking forward to read more. Much obliged.
I truly appreciate this blog article.Thanks Again. Keep writing.
Major thanks for the article post.Much thanks again. Really Cool.
Hey, thanks for the blog article.Much thanks again. Much obliged.
Fantastic post. Will read on…
Say, you got a nice blog. Will read on…
I just like the helpful info you supply for your articles.
I will bookmark your blog and take a look at once more right
here frequently. I’m quite certain I will be told lots of new stuff proper right here!
Good luck for the next!
Very good blog.Really looking forward to read more. Fantastic.
Thanks a lot for the blog.Much thanks again.
I loved your blog.Much thanks again. Great.
Very rapidly this web site will be famous amid all blog
viewers, due to it’s pleasant articles or reviews
Excellent post. Keep writing such kind of info on your blog.
Im really impressed by it.
Hey there, You’ve performed a great job. I’ll certainly
digg it and in my opinion recommend to my friends.
I am confident they will be benefited from this website.
New York Rapper B-Rock releases his first Dance EP . Titled ( 4 songs 4 Tha club)at CD Baby
After looking over a handful of the blog posts on your website, I truly appreciate your technique of writing
a blog. I saved as a favorite it to my bookmark website list and will be checking back soon. Please check
out my website too and let me know how you feel.
Thanks for the article post.Much thanks again. Cool.
If you would like to improve your knowledge just keep visiting this site and be updated with the most up-to-date news posted here.
I am so grateful for your blog post.Thanks Again. Awesome.
I think this is a real great blog.Really thank you! Will read on…
That is a really good tip particularly to those new to the blogosphere.
Simple but very precise information… Thanks for sharing this one.
A must read article!
Thank you ever so for you article.Really looking forward to read more.
Really enjoyed this blog article.Much thanks again. Fantastic.
Say, you got a nice blog.Thanks Again. Really Great.
Im thankful for the blog.Really looking forward to read more. Will read on…
I appreciate you sharing this article post.Really looking forward to read more.
Really appreciate you sharing this blog post.Thanks Again. Really Great.
Does your site have a contact page? I’m having trouble locating it but, I’d like to shoot
you an e-mail. I’ve got some creative ideas for your blog you might
be interested in hearing. Either way, great website and I look forward to seeing it improve over time.
Thanks for the post.Really thank you! Keep writing.
Hey, thanks for the article.Really looking forward to read more.
I appreciate you sharing this blog.Really thank you! Great.
wow, awesome blog post.Really looking forward to read more. Much obliged.
Thank you ever so for you blog article. Will read on…
Enjoyed every bit of your article. Awesome.
Thanks again for the article.Thanks Again.
I truly appreciate this blog post.Much thanks again. Really Great.
A round of applause for your blog article.Really looking forward to read more. Much obliged.
Really informative blog.Thanks Again. Will read on…
Hi I am so delighted I found your weblog, I really found you by mistake,
while I was searching on Askjeeve for something else, Anyways I am here now and would just like to say cheers for
a remarkable post and a all round thrilling blog (I also love the theme/design), I don’t have time to read through 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 great b.
Really enjoyed this article post.Much thanks again. Want more.
Say, you got a nice blog. Keep writing.
This is one awesome post.Really looking forward to read more. Cool.
A round of applause for your blog article.Much thanks again. Great.
Wow, great blog post.Really thank you! Awesome.
Hey, thanks for the blog post.Much thanks again. Cool.
Great, thanks for sharing this article post.Really thank you! Really Cool.
I think this is a real great article. Will read on…
This is a topic that’s close to my heart… Cheers!
Exactly where are your contact details though?
I loved your blog.Much thanks again. Great.
Im grateful for the article post.Much thanks again. Much obliged.
Wow, great post. Really Great.
Major thankies for the blog.Really looking forward to read more. Great.
It’s remarkable to pay a visit this web page and reading the views of all mates regarding this post, while I am also keen of getting
know-how.
This is one awesome article post.Really thank you! Will read on…
I loved your blog article.
Im grateful for the article post.Really thank you! Want more.
Really enjoyed this blog post. Want more.
Fantastic post.Thanks Again. Awesome.
This is one awesome article.Thanks Again. Cool.
Fantastic blog.Much thanks again. Will read on…
Very good article.Really looking forward to read more. Keep writing.
Great blog article.Really thank you! Cool.
I value the blog post.Much thanks again. Great.
Really enjoyed this post. Want more.
Wow, great blog post.Really thank you! Keep writing.
Really informative post. Keep writing.
Enjoyed every bit of your blog post.Thanks Again. Will read on…
Thanks a lot for the blog post.Really thank you! Keep writing.
I cannot thank you enough for the blog post.Much thanks again. Great.
Hi, i think that i saw you visited my site thus i came to return the
want?.I am trying to find issues to enhance my website!I guess its adequate to make use of a
few of your concepts!!
Looking forward to reading more. Great blog article.Thanks Again. Awesome.
Im grateful for the blog post.Really looking forward to read more. Fantastic.
A round of applause for your article. Really Great.
Thank you ever so for you blog.Really looking forward to read more.
Fantastic blog. Really Cool.
I appreciate you sharing this article. Really Cool.
Thanks again for the article. Much obliged.
I love your blog.. very nice colors & theme. Did you make this website yourself or did you hire someone to do it for you? Plz respond as I’m looking to create my own blog and would like to know where u got this from. appreciate it
Thanks-a-mundo for the post.Really thank you! Awesome.
I am so grateful for your post.Really looking forward to read more. Keep writing.
Enjoyed every bit of your blog article.Thanks Again. Really Cool.
Thanks so much for the post.Really looking forward to read more. Keep writing.
I truly appreciate this post.Thanks Again. Fantastic.
Really appreciate you sharing this post. Really Cool.
Im thankful for the article post.Much thanks again. Will read on…
Wow, great article.Really looking forward to read more. Want more.
I am so grateful for your article post.Thanks Again. Cool.
Thanks-a-mundo for the article.Much thanks again. Really Great.
Awesome article.Really looking forward to read more. Much obliged.
I truly appreciate this blog post.Much thanks again. Will read on…
Hey, thanks for the article post.Much thanks again. Keep writing.
Im obliged for the article post.Much thanks again.
I truly appreciate this blog article.Much thanks again. Want more.
Thanks-a-mundo for the blog article. Awesome.
Thank you ever so for you blog. Awesome.
Major thanks for the blog.Really thank you! Much obliged.
Major thankies for the article. Awesome.
Enjoyed every bit of your blog article.Thanks Again. Much obliged.
I appreciate you sharing this blog.Really looking forward to read more. Much obliged.
Thanks a lot for the blog post.Much thanks again. Want more.
This is one awesome post.Thanks Again.
I appreciate you sharing this post.Much thanks again. Keep writing.
Im obliged for the blog post.Really looking forward to read more.
Looking forward to reading more. Great blog post.Thanks Again. Awesome.
Really appreciate you sharing this article post.Really looking forward to read more. Really Cool.
I loved your blog.Much thanks again. Awesome.
Really informative blog article.Thanks Again. Want more.
Wow, great article post.Really looking forward to read more. Awesome.
Very informative blog post.Much thanks again. Much obliged.
Hey, thanks for the article.Thanks Again. Awesome.
Really appreciate you sharing this article. Great.
Wow, great blog.Really thank you! Awesome.
I really like and appreciate your blog article. Awesome.
Really appreciate you sharing this blog. Keep writing.
Very neat article.Much thanks again. Cool.
Muchos Gracias for your blog.Really thank you! Cool.