相关链接
题目传送门:http://codeforces.com/contest/212/problem/B
中文题面:http://www.tsinsen.com/A1470
解题报告
这题你需要观察到一个非常重要的结论:
以字符串某个特定位置为开头的字符串,至多只有26个会产生贡献
于是我们就可以暴力枚举这$O(26n)$的字符串
然后去更新答案
时间复杂度:$O(26n \log q)$
Code
这份代码我写挫了
时间复杂度是:$O(676n \log q)$的
#include<bits/stdc++.h> #define LL long long using namespace std; const int N = 1000009; const int SGZ = 26; const int M = 10009; int n, m, nxt[N][SGZ], crt[N][SGZ], q[M], ans[M]; vector<int> val; char s[N], qy[SGZ]; inline int read() { char c = getchar(); int ret = 0, f = 1; while (c < '0' || c > '9') { f = c == '-'? -1: 1; c = getchar(); } while ('0' <= c && c <= '9') { ret = ret * 10 + c - '0'; c = getchar(); } return ret * f; } inline int index(int x) { for (int l = 0, r = val.size() - 1, mid; l <= r; ) { mid = l + r >> 1; if (val[mid] == x) { return mid; } else if (val[mid] < x) { l = mid + 1; } else { r = mid - 1; } } return -1; } int main() { scanf("%s", s); n = strlen(s); m = read(); for (int i = 1; i <= m; i++) { scanf("%s", qy); int len = strlen(qy); for (int j = 0; j < len; j++) { q[i] |= 1 << qy[j] - 'a'; } val.push_back(q[i]); } sort(val.begin(), val.end()); val.resize(unique(val.begin(), val.end()) - val.begin()); int last_position[SGZ]; fill(last_position, last_position + SGZ, n); for (int i = n - 1; ~i; i--) { last_position[s[i] - 'a'] = i; for (int j = 0; j < SGZ; j++) { nxt[i][j] = last_position[j]; } } memset(crt, -1, sizeof(crt)); for (int i = 0; i < n; i++) { for (int j = 0, p = i, sta = 0; j < 26 && p < n; j++) { int np = n, c = -1; for (int k = 0; k < 26; k++) { if ((sta >> k & 1) == 0) { if (np > nxt[p][k]) { c = k; np = nxt[p][k]; } } } if (~c) { sta |= 1 << c; p = np; crt[i][j] = sta; if (!i || crt[i - 1][j] != sta) { int idx = index(sta); if (~idx) { ans[idx]++; } } } } } for (int i = 1; i <= m; i++) { printf("%d\n", ans[index(q[i])]); } return 0; }
Wow, great blog.Really thank you!
I really like and appreciate your article post. Will read on…
Enjoyed every bit of your blog.Really thank you! Great.
I really liked your blog.Much thanks again. Cool.
This is one awesome blog article.Really looking forward to read more. Keep writing.
Thanks again for the article post.Thanks Again. Will read on…
Thanks-a-mundo for the blog.Much thanks again. Want more.
I appreciate you sharing this post.Thanks Again. Cool.
I am so grateful for your post.
wow, awesome blog.Thanks Again. Cool.
I appreciate you sharing this blog article. Will read on…
Say, you got a nice article. Great.
I am so grateful for your article post.Much thanks again. Want more.
Im obliged for the article.Thanks Again.
Thank you for your blog post.Really thank you! Fantastic.
Im thankful for the blog article.Really looking forward to read more.
Im obliged for the article post.Thanks Again.
Appreciate you sharing, great blog article.Thanks Again. Awesome.
Im grateful for the blog post.Much thanks again. Much obliged.
Enjoyed every bit of your blog.Much thanks again. Really Cool.
Say, you got a nice blog post.Much thanks again. Really Great.
Hey, thanks for the article.Really thank you!
A round of applause for your blog post.Really looking forward to read more. Great.
Very neat article post.Thanks Again. Awesome.
I think this is a real great blog article.Thanks Again.
Im obliged for the article. Really Great.
This is one awesome post.Really thank you! Keep writing.
I really like and appreciate your blog.Thanks Again. Much obliged.
Major thankies for the blog.Much thanks again.
Thank you ever so for you article post.Much thanks again. Will read on…
Great, thanks for sharing this post.Really thank you! Great.
Really appreciate you sharing this post.Really looking forward to read more. Great.
Really appreciate you sharing this article.Thanks Again. Fantastic.
I appreciate you sharing this blog.Really looking forward to read more. Great.
A round of applause for your post.Really looking forward to read more. Awesome.
I cannot thank you enough for the post.Really looking forward to read more. Great.
Thank you ever so for you blog.Really thank you! Really Great.
Thanks for sharing, this is a fantastic blog post.Really thank you! Keep writing.
Really enjoyed this blog article.Thanks Again. Want more.
I am thankful for the article post. Thanks Again.
I value the blog.Really thank you! Really Great.
Wow, amazing weblog structure! How long have you ever been blogging
for? you make blogging look easy. The full glance of your
site is magnificent, as neatly as the content material!
This is one awesome article post.Really thank you! Much obliged.
Very good post.Much thanks again. Will read on…
I really enjoy the blog post.Much thanks again.
Very neat post.Really thank you! Keep writing.
This is one awesome blog.Thanks Again. Cool.
Really enjoyed this blog post.Much thanks again. Really Cool.
Thanks again for the article post.Much thanks again. Fantastic.
Hey there, You’ve done a fantastic job.
I will definitely digg it and personally recommend to my friends.
I’m confident they will be benefited from this website.
Great article post. Will read on…
Your writing taste has been surprised me. Thank you, quite nice post.
Say, you got a nice blog post.Really thank you! Great.
Very informative article.Really thank you! Keep writing.
Fantastic blog article. Much obliged.
I really like and appreciate your article post.Much thanks again. Want more.
Wow, great blog article. Awesome.
Thanks-a-mundo for the article post.Really thank you! Awesome.
Really informative article.Really looking forward to read more. Really Cool.
Thanks again for the article post.Thanks Again. Fantastic.
Really appreciate you sharing this article post.Really thank you! Want more.
I think this is a real great blog article. Really Cool.
I am curious to find out what blog system you’re utilizing?
I’m having some minor security issues with
my latest blog and I’d like to find something more safe.
Do you have any suggestions?
Major thankies for the blog article.Really thank you! Awesome.
I truly appreciate this post.Much thanks again. Cool.
Thanks-a-mundo for the blog article.Much thanks again. Fantastic.
I am so grateful for your blog article.Much thanks again. Really Cool.
Im obliged for the article post. Really Great.
Wow, great article. Will read on…
A big thank you for your article.Really looking forward to read more. Really Great.
Awesome article post.Really looking forward to read more. Much obliged.
Thanks a lot for the article post.Really thank you! Will read on…
Really appreciate you sharing this article post. Really Great.
Enjoyed every bit of your blog post. Much obliged.
This is one awesome article.Really thank you! Want more.
Im grateful for the article.Really looking forward to read more. Great.
Superb, what a weblog it is! This blog presents
useful data to us, keep it up.
Muchos Gracias for your post. Fantastic.
Thanks so much for the article.Thanks Again. Great.
I’m not sure why but this weblog is loading incredibly slow for me.
Is anyone else having this issue or is it a issue on my end?
I’ll check back later on and see if the problem still exists.
Muchos Gracias for your blog article.Really looking forward to read more. Great.
Very informative article post.Thanks Again.
I am so grateful for your post.Much thanks again. Will read on…
Thanks for the blog.Much thanks again. Cool.
Thanks so much for the blog article.Much thanks again. Much obliged.
Muchos Gracias for your article post.Really thank you! Want more.
I really like and appreciate your blog.Really thank you! Much obliged.
Great article post.
Appreciate you sharing, great post.Really thank you! Awesome.
Really appreciate you sharing this blog.Really looking forward to read more. Want more.
Hi there to all, how is all, I think every one is getting more from this web page, and your
views are pleasant in favor of new viewers.
Im obliged for the article.Really thank you! Fantastic.
Muchos Gracias for your article post.Thanks Again. Will read on…
Hey just wanted to give you a brief heads up and let you know a few
of the pictures aren’t loading correctly. I’m not sure why but I think its a linking issue.
I’ve tried it in two different browsers and both
show the same outcome.
Hey, thanks for the blog post.Much thanks again.
Only a smiling visitant here to share the love (:, btw great pattern.
Really appreciate you sharing this article post.Really thank you!
Appreciate you sharing, great blog post.Thanks Again. Cool.
I really liked your blog post.Really looking forward to read more. Really Great.
Im thankful for the blog post.Really looking forward to read more. Really Cool.
I just like the helpful information you supply for your articles.
I will bookmark your blog and take a look at again here regularly.
I am reasonably sure I will learn many new stuff right here!
Good luck for the following!
Thanks for the blog.Much thanks again. Cool.
I cannot thank you enough for the post.Much thanks again. Want more.
Thanks again for the blog post. Awesome.
Fantastic blog post.Really thank you! Really Great.
I think this is a real great article.Really thank you! Much obliged.
I think this is a real great blog.Really thank you! Fantastic.
Thanks for this amazing Post admin, I love your website.
Thank you for your blog post.Really thank you! Cool.
Very neat blog post.Much thanks again. Keep writing.
Appreciate you sharing, great blog.Thanks Again. Keep writing.
Thanks for sharing, this is a fantastic post.Thanks Again. Will read on…
I loved your blog.Really looking forward to read more. Much obliged.
Thanks for sharing, this is a fantastic blog.Really looking forward to read more. Awesome.
Major thankies for the blog post.Thanks Again. Great.
I cannot thank you enough for the post. Cool.
This is one awesome blog article.Really looking forward to read more. Really Cool.
Wow, great blog post.Much thanks again. Awesome.
Thanks so much for the post.Really looking forward to read more. Really Great.
Wow, great article post.Really thank you! Will read on…
Very informative blog article. Awesome.
I think this is a real great blog article.Much thanks again. Keep writing.
Very informative blog article.Really thank you! Great.
This is one awesome post.Really thank you! Fantastic.
Wow, great blog post.Really looking forward to read more. Awesome.
I really enjoy the blog. Much obliged.
I like the helpful information you provide in your articles.
I will bookmark your weblog and check again here frequently.
I am quite sure I will learn lots of new stuff right here!
Best of luck for the next!
Do you have a spam problem on this website; I also am a blogger, and I was
wondering your situation; we have created some nice practices and
we are looking to exchange methods with others, why not shoot me an e-mail if interested.
I really enjoy the blog article. Want more.
Thanks for the blog post.Really thank you! Keep writing.
Im grateful for the blog post. Great.
If you desire to get a good deal from this piece of writing then you have to apply these methods to your won blog.
Thanks a lot for the blog article.Much thanks again. Much obliged.
Hey, thanks for the blog.Thanks Again. Much obliged.
Undeniably consider that that you said. Your favourite reason seemed to
be on the net the easiest factor to take into account of.
I say to you, I certainly get irked while folks think about
worries that they just do not recognize about.
You controlled to hit the nail upon the highest and
outlined out the whole thing with no need side-effects , people can take a signal.
Will probably be back to get more. Thank you
I really like and appreciate your blog post.Really thank you! Cool.
Major thankies for the article post.Thanks Again. Really Great.
I think the admin of this website is really working hard in favor of his web site, because here every information is quality based stuff.
wow, awesome blog article. Much obliged.
A round of applause for your article.
Thanks again for the blog. Fantastic.
These kind of post are always inspiring and I prefer to read quality content so I happy to find many good point here in the post
Thanks again for the blog article. Keep writing.
Hello there! Do you know if they make any plugins to
safeguard against hackers? I’m kinda paranoid about
losing everything I’ve worked hard on. Any suggestions?
I really liked your blog article.Much thanks again. Fantastic.
Great, thanks for sharing this article.Really thank you! Really Great.
I truly appreciate this blog post.Really looking forward to read more. Really Cool.
Thanks so much for the article.Thanks Again. Really Great.
Thanks a lot for the blog article.Really looking forward to read more.
Major thankies for the blog article.Thanks Again. Much obliged.
Great, thanks for sharing this article.Really thank you! Much obliged.
Thanks a lot for the article post.Really thank you! Want more.
Thanks a lot for the post.Really looking forward to read more. Really Great.
This is one awesome article post.Really thank you! Keep writing.
Great article post.Really thank you! Will read on…
A round of applause for your article post. Awesome.
Thanks-a-mundo for the article.Really looking forward to read more. Will read on…
Thank you for your blog.Much thanks again. Great.
I value the blog article.Thanks Again. Fantastic.
A round of applause for your article post.Thanks Again. Will read on…
Im grateful for the blog. Really Cool.
Thank you ever so for you post. Much obliged.
I loved your article.Really looking forward to read more. Want more.
I really enjoy the post.Really thank you! Fantastic.
Wow, great article. Much obliged.
Hey, thanks for the blog article.Really looking forward to read more.
Great, thanks for sharing this article post.Thanks Again. Fantastic.
Really informative blog article. Keep writing.
Thanks again for the blog.Thanks Again. Fantastic.
Hi, just wanted to mention, I liked this blog post.
It was practical. Keep on posting!
Fantastic blog post.Really looking forward to read more. Much obliged.
Wow, great article. Want more.
I appreciate you sharing this article.Much thanks again. Much obliged.
Major thankies for the blog post.Much thanks again. Great.
Hey, thanks for the article.Really looking forward to read more. Keep writing.
Looking forward to reading more. Great blog post.Really looking forward to read more.
Great article.Really thank you! Really Cool.
Awesome blog.Thanks Again. Awesome.
Very neat blog article.Really thank you! Fantastic.
I believe everybody went like Ones New website, reason being things like this site without doubt has a article on quality. I loved read A New content. go on To remain a useful article, I will avail Once more by One additional time. Bless you.
Awesome article post. Really Cool.
Major thankies for the article.Much thanks again. Much obliged.
Really enjoyed this post.Really looking forward to read more. Keep writing.
Really enjoyed this blog article.Really looking forward to read more. Really Cool.
Muchos Gracias for your post.Really thank you! Really Cool.
Thanks again for the blog.Really thank you! Really Cool.
Major thanks for the blog article.Really looking forward to read more. Will read on…
A round of applause for your article.Much thanks again. Really Great.
Im grateful for the blog article.Thanks Again. Will read on…
Very neat blog article.Thanks Again. Will read on…
Fantastic article post.Much thanks again. Great.
Thank you for your blog.Really looking forward to read more. Fantastic.
I am so grateful for your article. Want more.
Thanks again for the article.Really looking forward to read more. Will read on…
Thanks again for the article.Really thank you! Want more.
Appreciate you sharing, great blog article.Thanks Again. Really Great.
Thank you ever so for you blog post.Thanks Again. Awesome.
Very informative post. Really Cool.
Looking forward to reading more. Great blog article.Thanks Again. Really Cool.
Really enjoyed this blog article.Much thanks again. Really Great.
Thank you for your post. Want more.
I will right away grab your rss as I can not find your email subscription link or
newsletter service. Do you’ve any? Kindly allow me realize so that I may subscribe.
Thanks.
I loved your article.Really looking forward to read more.
Im grateful for the article post.Thanks Again. Fantastic.
I loved your article post. Cool.
Thank you ever so for you blog post. Want more.
Awesome post.Really thank you! Want more.
Thanks-a-mundo for the blog.Really looking forward to read more. Keep writing.
What’s Happening i’m new to this, I stumbled upon this I have found It positively useful
and it has aided me out loads. I’m hoping to contribute & aid other customers like its aided me.
Good job.
You could certainly see your enthusiasm in the paintings you write. The arena hopes for even more passionate writers such as you who are not afraid to mention how they believe. All the time follow your heart. “Every man serves a useful purpose A miser, for example, makes a wonderful ancestor.” by Laurence J. Peter.
Very informative blog article. Great.
Hi there, I enjoy reading through your article post.I wanted to write a little comment to support you.
Greetings from Ohio! I’m bored to death at work soI decided to check out your site on my iphone during lunch break.I love the information you provide here and can’t wait to take alook when I get home. I’m shocked at how quick your blog loaded on my mobile ..I’m not even using WIFI, just 3G .. Anyways, great blog!
Im obliged for the article post.Really thank you! Want more.
Thank you, I’ve just been looking for information approximately this topic for agesand yours is the greatest I’ve came upon so far. But, what about the bottomline? Are you sure in regards to the supply?
A round of applause for your blog.Really thank you! Much obliged.
Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You obviously know what youre talking about, why throw away your intelligence on just posting videos to your blog when you could be giving us something informative to read?
I cannot thank you enough for the post.Really looking forward to read more. Cool.
Thank you ever so for you article post.
Say, you got a nice blog post.Really thank you! Awesome.
Thank you for your blog.Really thank you! Keep writing.
Enjoyed every bit of your article post.Really looking forward to read more. Want more.
I am so grateful for your post.Really thank you! Will read on…
Awesome article.Much thanks again. Will read on…
I am sure this article has touched all the internet viewers, its really reallynice paragraph on building up new web site.
Looking forward to reading more. Great blog post.Really looking forward to read more. Great.
Im grateful for the blog article.Really looking forward to read more.
[url=https://azithromycinzpak.com/]azithromycin 500mg price[/url] [url=https://allopurinol365.com/]buy allopurinol 300 mg[/url] [url=https://allopurinolzyl.com/]allopurinol 209[/url] [url=https://levitravard.com/]levitra 20 mg india price[/url]
I think this is a real great blog post.Really looking forward to read more. Really Cool.
I am so grateful for your blog article.Thanks Again. Will read on…
Thanks again for the blog article.Much thanks again. Fantastic.
Thanks so much for the blog post.Really thank you! Want more.
Its such as you learn my thoughts! You appear to know so muchapproximately this, such as you wrote the e-book in it orsomething. I feel that you just could do with a few to pressurethe message home a little bit, however other than that, that isgreat blog. A fantastic read. I’ll certainly be back.
Awesome article post.Really looking forward to read more. Cool.
Balıkesir evden eve nakliyat hızlı bir şekilde yükseliş yakalamış ve detaylı hizmetleri ile birlikte insanlar için planlama ortaya koymuş firmaların, buradaki sonuçlarına bakmak gerekmektedir. Müşteri memnuniyetinin önemini her türlü standart sektörde görmek gerekiyor. Müşterisi için çalışan firmaların özellikle gelişim noktasında daha iyi bir yere gelmesi planın bir parçası olarak dikkat çekmektedir. Gerek ticari piyasaya gerekse de bireysel insan ihtiyacına cevap veren Balıkesir evden eve nakliyat ile birlikte, burada ayrıntılardaki gizli hedefi bulmak çok daha kolay olmuştur. Kendine ve müşterilerine en iyi şekilde davranan firma anlayışı, gerekli sektör hassasiyeti ile birlikte iyi bir çözüm yaratmak durumundadır. Uygun teklifler için özellikle internet üzerinden yapacağınız detaylı araştırmalar, makul fiyat garantisi için sizi en iyi sonuçlara götürecektir.
Major thanks for the blog post.Really thank you! Fantastic.
Say, you got a nice post.Thanks Again. Fantastic.
Hi colleagues, how is the whole thing, and what you desire to say concerning this paragraph, in my view its genuinely amazing designed for me.|
Thank you ever so for you blog article. Much obliged.
Really appreciate you sharing this article.Thanks Again.
Nice post. I was checking constantly this weblog and I’m impressed! Extremely helpful info particularly the closing section 🙂 I maintain such information much. I was seeking this certain information for a long time. Thank you and best of luck. |
I’ll right away grab your rss as I can’t find your email subscription hyperlink or e-newsletter service. Do you have any? Kindly let me understand in order that I may subscribe. Thanks.|
Nice post. I was checking continuously this blog and I’m impressed! Extremely helpful information specially the last part 🙂 I care for such info much. I was seeking this particular information for a very long time. Thank you and best of luck.|
Thanks-a-mundo for the blog article. Cool.
Major thankies for the blog post.Much thanks again. Will read on…
What’s up, constantly i used to check webpage posts here in the early hours in the break of day, as i like to learn more and more.|
Very good blog article. Keep writing.
Thanks so much for the blog article.Really looking forward to read more. Cool.
This is one awesome blog.Really looking forward to read more. Really Great.
Looking forward to reading more. Great blog article.Much thanks again.
Greetings! Quick question that’s totally off topic. Do you know how to make your site mobile friendly? My site looks weird when viewing from my apple iphone. I’m trying to find a theme or plugin that might be able to correct this issue. If you have any suggestions, please share. Thank you!|
Awesome post.Really thank you! Much obliged.
Appreciate you sharing, great article post.Really thank you! Great.
Hmm is anyone else experiencing problems with the images on this blog loading? I’m trying to determine if its a problem on my end or if it’s the blog. Any feedback would be greatly appreciated.|
Thank you ever so for you post.Thanks Again. Awesome.
Major thanks for the article.Thanks Again. Cool.
Thanks so much for the post.Much thanks again. Much obliged.
Thanks so much for the post.Really looking forward to read more.
That is very interesting, You are an overly professional blogger. I’ve joined your rss feed and sit up for searching for more of your fantastic post. Also, I have shared your website in my social networks|
Wonderful site. Lots of useful information here. I am sending it to some friends ans additionally sharing in delicious. And naturally, thanks for your effort!|
I really like and appreciate your article.Really thank you! Cool.
Thanks for the article post.Really thank you! Awesome.
Fantastic blog. Much obliged.
Excellent way of telling, and good article to take data concerning my presentation topic, which i am going to present in school.|
always i used to read smaller articles or reviews which also clear their motive, and that is also happening with this post which I am reading at this time.|
Howdy! I know this is kinda off topic however I’d figured I’dask. Would you be interested in trading links or maybe guest writinga blog post or vice-versa? My website covers a lot of the same subjects as yours and I feel we could greatlybenefit from each other. If you’re interested feel freeto shoot me an email. I look forward to hearingfrom you! Fantastic blog by the way!
casino app android echt geld , kauhajoki casino — coez faccio un casino : juegos de casino tragamonedas .
Hello to all, how is everything, I think every one is getting more from this site, and your views are pleasant for new visitors.|
Really appreciate you sharing this blog.Really looking forward to read more. Great.
Excellent post. I will be dealing with many of these issues as well..|
Thanks a lot for the post.Much thanks again. Awesome.
Hey, thanks for the blog post. Awesome.
I think this is a real great blog article.Much thanks again.
Appreciate you sharing, great article post.Thanks Again. Awesome.
This is one awesome post.Really looking forward to read more. Fantastic.
you are in point of fact a good webmaster. The site loading pace is amazing. It sort of feels that you’re doing any distinctive trick. In addition, The contents are masterwork. you have performed a fantastic job in this subject!|
After going over a few of the articles on your site, I seriously like your technique of writing a blog. I book marked it to my bookmark website list and will be checking back soon. Take a look at my web site as well and tell me your opinion.|
Thanks-a-mundo for the blog article.Really thank you! Fantastic.
I really like and appreciate your post.Really looking forward to read more. Great.
Major thankies for the blog post. Really Cool.
I cannot thank you enough for the blog post.Much thanks again. Really Cool.
Thanks for finally writing about > blog_title < Loved it!|
I visited many web sites however the audio feature for audio songs existing at this website is actually marvelous.|