题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3620
离线版题目:http://paste.ubuntu.com/17950176/
求字串的前缀和后缀相等。WTF,这不14年的动物园吗?
又用到KMP的fail_chain就是从大到小遍历原串前缀的前后缀相等长度
然后O(n^2)暴力
1A! 撒花! *★,°*:.☆\( ̄▽ ̄)/$:*.°★*
#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int MAXN = 15000+9; char pat[MAXN]; int fail[MAXN],vout,N,k; inline void solve(char *s, int n){ fail[0] = fail[1] = 0; for (int i=2,j=0;i<=n;i++){ while(j && s[j+1] != s[i]) j = fail[j]; if (s[j+1] == s[i]) j++; fail[i] = j; } for (int i=k*2+1,t=i;i<=n;i++,t=i) { while ((fail[t])*2+1 > i) t = fail[t]; if (fail[t] >= k) vout++; } } int main(){ scanf("%s%d",pat+1,&k); N = strlen(pat+1); for (int i=1;i<=N-k*2;i++) solve(pat+i-1,N+1-i); printf("%d\n",vout); return 0; }
其实之前想了一想,貌似SA有希望在O(n)的时间复杂度内解决?
搞出sa[]之后,上下以k为限制扫一扫,统计统计。但这样时间复杂度我只能证到是O(n^2)的,还常数还比KMP大
Thanks so much for the article post.Thanks Again. Really Cool.
Really enjoyed this blog post.Much thanks again. Cool.
Thank you for your blog post.Much thanks again. Keep writing.
Say, you got a nice article. Great.
Great blog article.Thanks Again. Much obliged.
Hey, thanks for the post.Really looking forward to read more. Keep writing.
Thanks a lot for the article post.Really thank you! Will read on…
This is one awesome blog article.Thanks Again. Really Cool.
Really informative article post.Much thanks again. Want more.
Thank you ever so for you blog article.Really looking forward to read more.
I really liked your article post.Really looking forward to read more. Awesome.
I truly appreciate this article.Much thanks again. Really Great.
I loved your blog article.Much thanks again. Keep writing.
I really like and appreciate your post.Much thanks again. Will read on…
Appreciate you sharing, great blog.Really thank you! Cool.
Thanks again for the blog.Much thanks again. Keep writing.
This is one awesome blog.Much thanks again. Really Great.
Really informative blog article.Really looking forward to read more. Cool.
Muchos Gracias for your article post. Really Cool.
Enjoyed every bit of your blog post.Really thank you! Really Great.
Im obliged for the blog post.Much thanks again. Great.
Thanks-a-mundo for the article. Awesome.
Muchos Gracias for your post. Cool.
I cannot thank you enough for the blog post.Really thank you! Will read on…
I appreciate you sharing this post. Will read on…
Very neat article.Really looking forward to read more. Awesome.
Thanks again for the post.Thanks Again. Great.
Enjoyed every bit of your article.Really looking forward to read more. Really Cool.
Major thankies for the blog.Really thank you! Want more.
Awesome article.Really looking forward to read more. Cool.
I really like and appreciate your post.Really looking forward to read more. Much obliged.
Awesome post.Thanks Again. Fantastic.
Say, you got a nice article.Really thank you! Fantastic.
Im obliged for the blog post.Thanks Again. Much obliged.
Thanks a lot for the blog post.Really looking forward to read more. Awesome.
Im grateful for the blog. Cool.
Awesome article.Thanks Again. Keep writing.
It’s awesome in support of me to have a site, which is valuable designed for
my experience. thanks admin
I loved your blog post.Really looking forward to read more. Awesome.
It’s a shame you don’t have a donate button! I’d without a doubt donate
to this superb blog! I suppose for now i’ll settle for book-marking and adding your RSS feed to my Google account.
I look forward to brand new updates and will talk about this blog with my Facebook group.
Chat soon!
I really like and appreciate your blog.Much thanks again. Great.
I cannot thank you enough for the article post.Really looking forward to read more. Great.
Major thanks for the article.Much thanks again. Keep writing.
Wow, great blog article.Much thanks again.
Fantastic post. Much obliged.
Very good post.Really thank you! Really Cool.
Hey, thanks for the article post.Much thanks again.
Really appreciate you sharing this article post.Really thank you! Want more.
I value the blog. Awesome.
Looking forward to reading more. Great blog post.Thanks Again. Cool.
Hey There. I discovered your weblog the usage of msn. This is a really well written article.
I will be sure to bookmark it and return to learn extra
of your useful info. Thank you for the post. I will definitely
return.
wow, awesome blog.Thanks Again. Really Great.
Wow, great blog post.Thanks Again. Will read on…
I loved your blog post.Really looking forward to read more. Awesome.
Hi my loved one! I wish to say that this post is amazing, nice written and
come with almost all important infos. I’d like to peer more posts like this
.
Very neat article post.Really thank you! Much obliged.
Thank you ever so for you blog.Really thank you! Really Great.
Enjoyed every bit of your article.Thanks Again. Much obliged.
Thanks a lot for the blog.Thanks Again. Really Cool.
Fantastic blog post. Awesome.
Good way of explaining, and pleasant paragraph to take information concerning my presentation subject matter, which i
am going to deliver in college.
Im grateful for the post.Really looking forward to read more. Awesome.
I loved your blog.Thanks Again. Much obliged.
I appreciate you sharing this post.Really looking forward to read more. Much obliged.
Looking forward to reading more. Great blog post. Really thank you
Appreciate you sharing, great blog.Thanks Again. Fantastic.
I was suggested this website by my cousin. I’m not sure whether this post is
written by him as nobody else know such detailed about my problem.
You are wonderful! Thanks!
Thanks a lot for the blog. Will read on…
I truly appreciate this blog.Thanks Again. Fantastic.
Thank you ever so for you post.Really looking forward to read more. Cool.
Say, you got a nice article post.Really looking forward to read more. Really Great.
I appreciate you sharing this post. Great.
My partner and I stumbled over here different web page and thought
I may as well check things out. I like what I see
so i am just following you. Look forward to looking at your web page
for a second time.
Awesome article.Really looking forward to read more.
Very good post.Thanks Again. Keep writing.
Thanks for sharing your thoughts on ps4 games. Regards
I think this is a real great blog post.Really thank you! Cool.
I loved your blog post.Really looking forward to read more. Really Cool.
Fantastic article.Much thanks again. Fantastic.
A big thank you for your article post.Much thanks again. Fantastic.
I truly appreciate this blog post. Great.
wow, awesome blog. Awesome.
This blog was… how do you say it? Relevant!!
Finally I’ve found something that helped me. Appreciate it!
Pretty part of content. I just stumbled upon your site and in accession capital to assert that I acquire
actually loved account your blog posts. Anyway I will be subscribing in your
feeds and even I achievement you access persistently quickly.
Very good blog article.Really thank you! Fantastic.
wow, awesome blog article.Really looking forward to read more. Want more.
Hi there, for all time i used to check website posts here in the early hours in the daylight, for the reason that i
like to gain knowledge of more and more.
I really like and appreciate your post.
Appreciate you sharing, great post. Great.
Looking forward to reading more. Great article post.Really looking forward to read more. Really Great.
Saved as a favorite, I love your web site!
Hi there! I know this is kinda off topic but 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 addresses a lot of the same
topics as yours and I believe we could greatly benefit from
each other. If you happen to be interested
feel free to shoot me an e-mail. I look forward to hearing from you!
Awesome blog by the way!
Looking forward to reading more. Great blog post. Much obliged.
Enjoyed every bit of your article post.Thanks Again. Really Great.
Thanks a lot for the blog.Thanks Again. Awesome.
Very neat blog.Thanks Again.
Thanks again for the blog article. Much obliged.
Greetings from Los angeles! I’m bored to death
at work so I decided to check out your site on my iphone during lunch
break. I love the information you present here
and can’t wait to take a look when I get home.
I’m amazed at how quick your blog loaded on my mobile .. I’m not even using WIFI, just 3G ..
Anyhow, wonderful blog!
wow, awesome article post.Much thanks again. Fantastic.
Thanks a lot for the blog post.Really looking forward to read more. Great.
I blog frequently and I really appreciate your information. This great article has truly peaked my
interest. I’m going to take a note of your website and
keep checking for new information about once per week.
I opted in for your Feed as well.
Very informative article post.Much thanks again. Awesome.
Wow, that’s what I was searching for, what a information! present
here at this blog, thanks admin of this web page.
Really enjoyed this article. Will read on…
Hi! I know this is kind of off topic but I was wondering which blog platform are you using for
this site? I’m getting tired of WordPress because I’ve had problems with hackers and I’m looking at options for another
platform. I would be awesome if you could point me
in the direction of a good platform.
Good write-up, I?¦m normal visitor of one?¦s web site, maintain up the excellent operate, and It’s going to be a regular visitor for a long time.
Wow, great blog.Really looking forward to read more. Great.
Thanks for sharing, this is a fantastic blog.Thanks Again.
A round of applause for your article post.Much thanks again. Cool.
A big thank you for your article.Much thanks again. Awesome.
Wow, that’s what I was looking for, what a material!
existing here at this weblog, thanks admin of this web page.
I truly appreciate this blog. Great.
Very informative article.Thanks Again. Really Cool.
I cannot thank you enough for the blog.Really thank you! Awesome.
Im grateful for the article post.Thanks Again. Awesome.
Thanks for sharing, this is a fantastic article post.Much thanks again. Much obliged.
wow, awesome article.Much thanks again. Awesome.
I think this is a real great post.Really looking forward to read more. Cool.
Really appreciate you sharing this blog post.Really thank you! Great.
Thanks so much for the blog post.Thanks Again. Really Cool.
A big thank you for your article.Thanks Again.
Thank you for your article.Thanks Again. Fantastic.
Fantastic article post.Really looking forward to read more. Keep writing.
Thank you for your article post.Thanks Again.
Hey, thanks for the article.Thanks Again. Keep writing.
Really appreciate you sharing this post.Thanks Again. Fantastic.
I really like and appreciate your blog article.Really thank you!
Im thankful for the blog.Really looking forward to read more. Awesome.
I am so grateful for your blog article.Really thank you! Will read on…
I think this is a real great blog.Much thanks again. Really Great.
Major thanks for the blog article.Much thanks again. Really Great.
I think this is a real great blog. Cool.
I loved your blog article.Really looking forward to read more. Really Cool.
Say, you got a nice article post.Really thank you! Really Cool.
I cannot thank you enough for the blog post.Really thank you! Awesome.
Thanks for the article.Thanks Again. Fantastic.
Really informative post.Much thanks again. Fantastic.
Major thanks for the post.Really looking forward to read more. Awesome.
Hey there! I know this is sort of off-topic however I needed to ask.
Does building a well-established blog such as yours take
a lot of work? I’m completely new to blogging however I do write in my journal
every day. I’d like to start a blog so I will be able to share
my own experience and feelings online. Please let me know if you have
any ideas or tips for new aspiring bloggers.
Thankyou!
Thanks a lot for the blog article.Really looking forward to read more. Great.
Enjoyed every bit of your article post.
Muchos Gracias for your article post. Fantastic.
I cannot thank you enough for the article. Want more.
Hi there I am so excited I found your website,
I really found you by accident, while I was searching on Bing for something else, Anyhow I am here now and would just like to say cheers for a remarkable post and a all round entertaining
blog (I also love the theme/design), I don’t have time to look over it all at the moment but I have book-marked it and also
included your RSS feeds, so when I have time I will be back to read a lot
more, Please do keep up the superb jo.
I really like and appreciate your post.Really looking forward to read more. Really Great.
A round of applause for your blog. Fantastic.
Im grateful for the article post.Much thanks again. Great.
Really enjoyed this article post.Thanks Again. Much obliged.
This is one awesome blog.Really looking forward to read more. Really Great.
Great, thanks for sharing this blog. Great.
Thanks for the post.Much thanks again. Really Great.
Fantastic blog.Much thanks again. Awesome.
wow, awesome blog.Really thank you! Awesome.
Thanks-a-mundo for the post.Really thank you! Really Great.
Appreciate you sharing, great article post.Really looking forward to read more.
Say, you got a nice blog post.Really looking forward to read more. Really Cool.
Looking forward to reading more. Great blog article. Much obliged.
I’ve been exploring for a bit for any high-quality articles or blog posts in this kind
of house . Exploring in Yahoo I eventually stumbled upon this web site.
Studying this info So i’m glad to show that I have an incredibly excellent uncanny feeling I found
out exactly what I needed. I most for sure will make certain to don?t forget this site and give it
a look on a continuing basis.
A big thank you for your post.Thanks Again. Keep writing.
Great, thanks for sharing this article post.Really looking forward to read more. Want more.
Hey there! This is my first visit to your blog! We are a group of volunteers and starting a new initiative in a community in the same niche.
Your blog provided us useful information to work on. You
have done a extraordinary job!
This is one awesome blog post. Much obliged.
Major thankies for the blog article.Much thanks again.
Thanks again for the blog article.Really looking forward to read more. Really Cool.
I am so grateful for your blog.Really looking forward to read more. Cool.
Great blog article.Much thanks again. Want more.
Very good post.Really looking forward to read more. Much obliged.
I really like and appreciate your blog post. Want more.
I loved your blog article. Want more.
Awesome blog.Much thanks again.
I really liked your article post.Really looking forward to read more. Fantastic.
Thanks for sharing, this is a fantastic blog article. Really Great.
Have you ever considered creating an ebook or guest
authoring on other sites? I have a blog centered on the same subjects you discuss and would love
to have you share some stories/information. I know my subscribers would appreciate your work.
If you’re even remotely interested, feel free to shoot me an e mail.
After going over a few of the blog articles on your site, I really appreciate your technique of blogging.
I saved as a favorite it to my bookmark webpage list and will be checking back soon. Please visit my web site too and tell me your opinion.
A big thank you for your article post.Really looking forward to read more. Will read on…
Very informative post. Fantastic.
Wow, great blog.Really thank you! Really Great.
Ahaa, its pleasant discussion about this article at this place at this weblog, I have read all that,
so at this time me also commenting here.
Im obliged for the blog.Much thanks again. Keep writing.
Wow, great blog post.Really looking forward to read more. Really Great.
A round of applause for your article.Really thank you! Keep writing.
Looking forward to reading more. Great blog post.Thanks Again. Awesome.
I really liked your blog.Really looking forward to read more. Really Cool.
I cannot thank you enough for the article post. Awesome.
Thanks a lot for the blog.Really thank you! Want more.
I really like and appreciate your article post.Really looking forward to read more. Awesome.
Very informative blog post.Really looking forward to read more. Keep writing.
Fantastic post.Much thanks again. Want more.
I truly appreciate this blog.Really thank you! Keep writing.
Say, you got a nice blog post. Will read on…
I will immediately clutch your rss as I can not in finding your
email subscription hyperlink or newsletter service.
Do you’ve any? Kindly permit me understand so that I may subscribe.
Thanks.
I loved your blog article.Really thank you! Awesome.
Major thanks for the blog.Thanks Again. Really Cool.
Im obliged for the article post. Really Great.
Great, thanks for sharing this post.Much thanks again. Great.
Very informative blog post.Thanks Again. Cool.
Really appreciate you sharing this blog.
Really appreciate you sharing this article.Thanks Again. Really Great.
Very informative blog article.Much thanks again. Much obliged.
I really enjoy the blog post.Really looking forward to read more.
Really enjoyed this article.Much thanks again. Really Great.
Im obliged for the post.Thanks Again. Really Cool.
A big thank you for your post.Really thank you! Really Cool.
Im thankful for the blog article.Thanks Again. Really Great.
I think this is a real great blog article.Thanks Again. Cool.
Muchos Gracias for your post. Fantastic.
Really enjoyed this post.Really looking forward to read more. Fantastic.
Thanks so much for the blog article.Really looking forward to read more. Awesome.
Thanks for the blog article.Much thanks again. Cool.
I am so grateful for your blog post. Really Cool.
Hey, thanks for the post.Really thank you! Cool.
Thank you ever so for you article post.Really looking forward to read more. Will read on…
This is one awesome blog article.Really thank you! Will read on…
Very informative blog article.Thanks Again. Much obliged.
Really appreciate you sharing this article post.Really thank you! Cool.
Im obliged for the article.Really looking forward to read more. Great.
I really enjoy the article.Really looking forward to read more. Really Great.
WOW just what I was searching for. Came here by searching for sling tv
A big thank you for your article. Will read on…
Hello There. I found your blog using msn. This is a very well written article. I will be sure to bookmark it and come back to read more of your useful information. Thanks for the post. I will certainly comeback.
thank you web site admin
Im thankful for the article.Really thank you!
How long does a copyright last on newspaper articles?. . If a service copies newspapers articles and then posts it in a database on the Internet, is there also a copyright on the Internet content?.
Çıkan En Son Kitaplar Güzel Kitaplar
If you are great, you will attempt to bluff your opponents and make them think that you have a extremely good hand. This method is a great deal easier for people to be comfortable with telling you.
Hi everyone, it’s my first pay a quick visit at this web page, and post is truly fruitful in favor of me, keep
up posting these posts.
Major thanks for the post.Really thank you! Awesome.
Thanks again for the article post.
[url=https://hydrochlorothiazide2.com/]hydrochlorothiazide 125 mg[/url]
I cannot thank you enough for the post.Thanks Again. Will read on…
I really enjoy the blog article.Thanks Again. Awesome.
I truly appreciate this post.Thanks Again. Great.
A round of applause for your post.Much thanks again. Will read on…
I just want to say I am very new to blogs and truly savored you’re web site. More than likely I’m likely to bookmark your website . You amazingly come with superb articles and reviews. Regards for sharing your webpage.
Im obliged for the article.Much thanks again. Really Cool.
I cannot thank you enough for the post.Really looking forward to read more. Will read on…
Hey, thanks for the blog article.Thanks Again. Fantastic.
Muchos Gracias for your article. Cool.
Appreciate you sharing, great blog article. Really Great.
Really enjoyed this post.Really looking forward to read more. Cool.
nike air max 1 sd 850 billiggame brian hartline mens jersey miami dolphins 82 alternate orange nfl billig,nike arizona cardinals 15 michael floyd white limited womens jersey billig,detroit tigers blank 2013 white jersey billig,women nike new orleans saints 66 ben grubbs game blac…
Im obliged for the article post.Really looking forward to read more.
I’m extremely impressed with your writing skills as well as with the layout on your blog. Is this a paid theme or did you customize it yourself? Anyway keep up the nice quality writing, it’s rare to see a great blog like this one nowadays..
Im obliged for the post.Much thanks again. Cool.
A round of applause for your article post. Really Great.
It’s actually a nice and useful piece of information. I’m satisfied that you shared this helpful information with us. Please keep us informed like this. Thank you for sharing.|
Hi, always i used to check weblog posts here early in the morning, since i like to find out more and more.|
Enjoyed every bit of your post.Thanks Again. Will read on…
I really like and appreciate your article. Cool.
I really like your blog.. very nice colors & theme. Did you create this website yourself or did you hire someone to do it for you? Plz reply as I’m looking to design my own blog and would like to find out where u got this from. appreciate it|
Appreciate this post. Will try it out.|
Looking forward to reading more. Great article.Really thank you!
Thanks a lot for the article post.Much thanks again. Really Great.
Really appreciate you sharing this post.Much thanks again. Fantastic.
Thanks again for the article.Thanks Again. Cool.
Thanks so much for the post.Much thanks again. Fantastic.
Thanks so much for the blog post. Really Great.
Wow, amazing weblog layout! How lengthy have you ever been running a blog for? you made running a blog glance easy. The whole look of your website is fantastic, let alone the content!
Thanks-a-mundo for the article post.Much thanks again. Great.
Major thankies for the blog article.Thanks Again. Much obliged.
Thank you a lot for sharing this with all people you actually recognise what you’re speaking approximately! Bookmarked. Please also discuss with my web site =). We can have a link alternate arrangement between us|
Really informative blog post. Fantastic.
I loved your article post.Really thank you! Much obliged.
Thanks a lot for the article.Thanks Again. Really Great.
Fantastic blog post. Keep writing.
Pretty! This was an extremely wonderful post. Thanks for providing these details.|
Thanks-a-mundo for the post.Thanks Again. Much obliged.
Do you mind if I quote a few of your posts as long as I provide credit and sources back to your site? My blog site is in the exact same area of interest as yours and my visitors would truly benefit from a lot of the information you present here. Please let me know if this ok with you. Many thanks!|
Hey, thanks for the blog post.Really thank you!
I cannot thank you enough for the blog.Much thanks again. Really Great.
thank you web site admin
My partner and I stumbled over here coming from a different website and thought I might as well check things out. I like what I see so now i’m following you. Look forward to looking into your web page yet again.|
very good publish, i definitely love this web site, carry on it
What i do not understood is in fact how you are not actually a lot more neatly-favored than you might be right now. You’re so intelligent. You realize thus considerably in relation to this subject, produced me for my part consider it from so many various angles. Its like women and men are not interested unless it is something to accomplish with Lady gaga! Your individual stuffs outstanding. Always care for it up!|
Very neat blog article.Really looking forward to read more. Want more.
Thank you ever so for you blog article.Really looking forward to read more. Want more.
A round of applause for your blog post.Really thank you!
Thanks for the post. Really Cool.
May I simply just say what a relief to discover someone who genuinely understands what they’re discussing over the internet. You definitely know how to bring a problem to light and make it important. More people have to look at this and understand this side of your story. It’s surprising you aren’t more popular because you certainly possess the gift.|
Really enjoyed this blog post.Really thank you! Keep writing.
Really informative article post.Really looking forward to read more. Awesome.
Hi, I desire to subscribe for this blog to take newest updates, thus where can i do it please assist.|
A big thank you for your blog. Much obliged.
Great, thanks for sharing this blog.Really looking forward to read more. Really Cool.
wow, awesome article post.Really looking forward to read more.
Thanks-a-mundo for the article post.Really looking forward to read more. Much obliged.
I am sure this piece of writing has touched all the internet people, its really really nice paragraph on building up new blog.|
I just like the valuable information you supply in your articles. I will bookmark your weblog and take a look at once more right here regularly. I am rather certain I will be told plenty of new stuff proper here! Best of luck for the next!|