# 【BZOJ 3103】[ONTAK2010] Palindromic Equivalence

### Code

#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int N = 2000009;
const int M = N << 1;
const int MOD = 1000000007;

char pat[N],s[N];
int n,ans=1,fa[N],rid[N],col[N];
vector<pair<int,int> > e;

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 find(int x) {
return x == fa[x]? x: fa[x] = find(fa[x]);
}

inline void manacher() {
for (int i=1,r=1,p=1,t;i<=n*2;i++) {
t = min(r - i, rid[p - (i - p)]);
while (s[i+t+1] == s[i-t-1]) t++, fa[find(i+t)] = find(fa[i-t]);
if ((rid[i] = t) + i > r) r = t + i, p = i;
e.push_back(make_pair(i - t - 1, i + t + 1));
}
}

inline void AddEdge(int u, int v) {
static int E = 1;
if (u == v || !(u & 1) || !(v & 1)) return;
}

int main() {
scanf("%s",pat+1); n = strlen(pat+1);
s[0] = '#'; s[n*2] = '@';
for (int i=1;i<=n;i++) s[i*2-1] = pat[i], s[i*2] = '*';
for (int i=1;i<=n*2;i++) fa[i] = i;
manacher();
for (int i=1,cnt;cnt=26,i<=n*2;i+=2) {
if (find(i) != i) continue; col[i] = 1;
if (col[to[j]] && vis[to[j]] < i)
--cnt, vis[to[j]] = i;
}
if (cnt <= 0) ans = 0;
else ans = (LL)ans * cnt % MOD;
}
cout<<ans;
return 0;
}


—————————— UPD 2017.4.26 ——————————

## 242 thoughts to “【BZOJ 3103】[ONTAK2010] Palindromic Equivalence”

1. 哇塞，居然是沙发？留个名

2. I have been exploring for a bit for any high quality articles or blog
posts in this sort of area . Exploring in Yahoo I eventually stumbled upon this site.

a very good uncanny feeling I came upon exactly what I needed.
I most unquestionably will make sure to do not overlook this web site
and give it a glance on a constant basis.

3. You really make it appear so easy together with your presentation but
I to find this topic to be really one thing which I believe
I’d by no means understand. It sort of feels too complicated and very
large for me. I’m looking ahead in your next publish, I will try to get the hang of it!

4. g说道：

Hi! Quick question that’s entirely off topic.
Do you know how to make your site mobile friendly?
My blog looks weird when browsing from my iphone 4.
I’m trying to find a template or plugin that might
be able to correct this problem. If you have any recommendations, please share.
Thanks!

5. Generally I don’t learn article on blogs, however I wish to say that this write-up very pressured me to check out and do so!
Your writing taste has been amazed me. Thanks, very great post.

6. Heya i’m for the primary time here. I found this board and I find It really useful & it helped me out a
lot. I am hoping to provide one thing back and aid others such as you helped me.

7. For newest news you have to go to see world-wide-web
and on web I found this website as a finest web page for newest updates.

8. Your style is unique compared to other folks I’ve read stuff from.
Thank you for posting when you have the opportunity, Guess I’ll just book mark this blog.

9. I’m really loving the theme/design of your site. Do you
ever run into any web browser compatibility issues? A small number of
my blog visitors have complained about my blog
not operating correctly in Explorer but looks great in Safari.
Do you have any solutions to help fix this problem?

10. Everyone loves what you guys are usually up
too. This kind of clever work and exposure! Keep up the terrific works guys I’ve included you guys to
blogroll.

11. I think the admin of this website is in fact working hard in favor of his
site, because here every information is quality based data.

12. Hello, all is going fine here and ofcourse every
one is sharing information, that’s genuinely excellent, keep up writing.

13. It’s enormous that you are getting ideas from this piece of writing as well as from our dialogue made at this time.

14. It’s in point of fact a nice and useful piece of information.
I’m happy that you shared this helpful information with us.
Please keep us informed like this. Thanks for sharing.

15. Hi colleagues, its great piece of writing about cultureand entirely
explained, keep it up all the time.

16. Thank you, I have recently been looking for information approximately this topic for a long time and yours is the greatest I’ve came upon till now.
But, what concerning the conclusion? Are you positive in regards to the source?

17. Hi I am so happy I found your web site, I really found
you by mistake, while I was browsing on Google for something else,
Nonetheless I am here now and would just like to say many thanks for a marvelous
post and a all round exciting blog (I also love the theme/design), I don’t have time to look
over it all at the minute but I have saved it and also added in your RSS feeds,
so when I have time I will be back to read a lot
more, Please do keep up the superb jo.

18. Excellent site. A lot of helpful information here. I’m sending it to a few pals
ans additionally sharing in delicious. And obviously,

19. Wow, wonderful blog layout! How long have you been blogging for?
is great, as well as the content!

20. Hello there I am so grateful I found your web site,
I really found you by error, while I was browsing
on Yahoo for something else, Nonetheless I am here now
and would just like to say kudos for a fantastic 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 minute but I have bookmarked it and also added in your RSS
feeds, so when I have time I will be back to read a lot more, Please
do keep up the great work.

21. Nice answer back in return of this issue with genuine arguments and telling all concerning that.

22. I’m not sure where you are getting your info, but
great topic. I needs to spend some time learning much more or understanding more.
Thanks for wonderful info I was looking for this info for my mission. natalielise pof

23. This is very interesting, You are a very skilled blogger. I have joined your feed and look forward to seeking more of your fantastic post.
Also, I’ve shared your web site in my social networks!

24. What’s up to every single one, it’s in fact a good for me
to visit this web page, it contains priceless Information.

25. I do not know if it’s just me or if everybody else experiencing
problems with your website. It seems like some of the written text on your posts are running off the screen. Can someone else please comment and let me know if this is happening to them
too? This might be a issue with my internet browser because I’ve had
this happen before. Cheers

26. I do not even understand how I stopped up here, however I assumed this submit was once
good. I do not understand who you’re however certainly you’re going to a famous blogger when you are not already.
Cheers!

27. Everything is very open with a really clear description of the challenges.
It was really informative. Your website is useful. Many thanks for sharing!

28. Hi! I know this is kinda off topic however I’d figured I’d ask.
Would you be interested in exchanging links or maybe guest writing
a blog post or vice-versa? My website goes over a lot of the same topics as yours and I believe we could greatly benefit
from each other. If you are interested feel free to send me
an e-mail. I look forward to hearing from you!
Awesome blog by the way! natalielise plenty of fish

29. I think what you typed made a bunch of sense.
But, consider this, what if you added a little content?

I mean, I don’t want to tell you how to run your website, but suppose you added something that makes
people want more? I mean 【BZOJ 3103】[ONTAK2010] Palindromic Equivalence – Qizy's Database is a little plain. You ought to peek at Yahoo’s
You might try adding a video or a pic or two to get readers excited
about what you’ve got to say. Just my opinion, it would make
your posts a little bit more interesting.

30. With havin so much content and articles do you ever run into
any problems of plagorism or copyright infringement?

My blog has a lot of unique content I’ve either authored
myself or outsourced but it looks like a lot of it is
popping it up all over the web without my agreement. Do you know any ways
to help prevent content from being ripped off?
I’d really appreciate it.

31. Nice post. I learn something new and challenging on blogs I stumbleupon everyday.
It’s always interesting to read content from other authors and practice something from their websites.

32. Very shortly this web page will be famous among all blog users,
due to it’s nice articles or reviews

33. Wonderful beat ! I wish to apprentice even as you amend your website, how can i subscribe for a weblog web site?

The account helped me a appropriate deal. I have been tiny bit acquainted of
idea

I like all of the points you have made.

35. This design is incredible! You certainly know how to keep a reader entertained.
Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!)
Great job. I really loved what you had to say, and more than that, how you
presented it. Too cool!

36. I love reading through a post that can make men and women think.
Also, thank you for allowing for me to comment!

37. Greetings I am so glad I found your website, I really found you by error,
while I was browsing on Digg for something else, Anyhow I am here now and
would just like to say cheers for a tremendous 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 minute but I have saved

38. Hello this is kinda of off topic but I was wondering if blogs use WYSIWYG editors or if you have to
manually code with HTML. I’m starting a blog soon but have no coding experience so
I wanted to get guidance from someone with experience.

Any help would be greatly appreciated!

39. I am extremely impressed with your writing skills as
well as with the layout on your blog. Is this a paid theme or did you modify
it yourself? Either way keep up the nice quality writing, it’s rare to see a nice blog like this

40. It is appropriate time to make a few plans for the long run and
it is time to be happy. I have learn this submit and if I may just I want to
recommend you few attention-grabbing things or tips. Perhaps you can write subsequent articles regarding this article.

41. always i used to read smaller posts that as well clear their motive, and that is also happening with this post which

42. Greetings! Quick question that’s totally off topic. Do
you know how to make your site mobile friendly?
My weblog looks weird when browsing from my iphone.
I’m trying to find a template or plugin that might be able to fix this problem.
If you have any suggestions, please share. Appreciate it!

43. I truly love your website.. Great colors & theme.
Did you develop this amazing site yourself? Please reply back as I’m trying
to create my very own website and want to know where you got this from or what
the theme is called. Appreciate it!

44. This post gives clear idea in favor of the new users of blogging, that really
how to do blogging.

45. I loved as much as you will receive carried out right
here. The sketch is attractive, your authored subject matter stylish.
nonetheless, you command get bought an nervousness over that you wish be delivering the following.
unwell unquestionably come more formerly again since exactly the same nearly a lot
often inside case you shield this hike.

46. I am sure this paragraph has touched all the internet people,
its really really pleasant article on building up new webpage.

47. Good day! This is kind of off topic but I
need some guidance from an established blog. Is it hard to set up your own blog?
I’m not very techincal but I can figure things out pretty quick.

I’m thinking about creating my own but I’m not sure where to begin. Do you have any points or suggestions?

Many thanks

48. Hi would you mind letting me know which webhost you’re using?
say this blog loads a lot faster then most. Can you suggest a good internet hosting provider at a fair price?
Thanks, I appreciate it!

49. Your style is so unique compared to other people I have read stuff
from. Many thanks for posting when you’ve got the opportunity,
Guess I’ll just book mark this blog.

50. I am so grateful for your post.Really looking forward to read more. Keep writing.

51. Wow, this piece of writing is fastidious, my younger sister is analyzing these kinds of things, thus I am going to convey her.

52. Thank you for the good writeup. It in fact was a amusement account
However, how can we communicate?

53. Thanks for the blog post.Really looking forward to read more. Fantastic.

55. Im grateful for the blog article.Thanks Again. Great.

56. With havin so much content and articles do you ever run into any issues of plagorism
or copyright infringement? My website has a lot of unique content I’ve either created myself or outsourced but it appears a lot of it is popping it up all over the
internet without my authorization. Do you
know any methods to help reduce content from being ripped
off? I’d really appreciate it.

57. Fantastic blog post.Really looking forward to read more. Really Cool.

58. Hey, thanks for the article. Really Great.

59. Really appreciate you sharing this blog.Really looking forward to read more. Great.

60. Im obliged for the post.Much thanks again. Want more.

62. I loved as much as you’ll receive carried out right here.
The sketch is attractive, your authored subject matter stylish.
nonetheless, you command get bought an impatience over that you wish be delivering the following.
unwell unquestionably come more formerly again since exactly the
same nearly a lot often inside case you shield this increase.

63. What’s up, constantly i used to check web site posts here
in the early hours in the dawn, because i love to find out more and more.

64. Hey, thanks for the blog post.Really looking forward to read more. Really Great.

65. I’m extremely impressed with your writing skills as well as with the layout on your weblog.
Is this a paid theme or did you modify it yourself? Either way keep up the excellent quality writing, it’s rare to
see a nice blog like this one nowadays.

66. Definitely consider that that you stated. Your favourite justification appeared to be on the
net the easiest thing to take into accout of.
I say to you, I definitely get irked at the same time as other people think about
worries that they just do not recognise about.
You managed to hit the nail upon the top as smartly as
outlined out the whole thing with no need side-effects ,
other people could take a signal. Will probably be again to get more.
Thanks

67. Asking questions are genuinely fastidious thing if you are not
understanding something completely, however this post gives pleasant understanding even.

69. This is one awesome blog article.Really thank you! Will read on…

70. Great post.Really thank you! Really Cool.

71. Im thankful for the blog article.Really thank you! Will read on…

72. Very good post.Really looking forward to read more. Keep writing.

73. Enjoyed every bit of your article.Thanks Again.

74. I really enjoy the blog post.Really thank you! Much obliged.

75. Fantastic blog post.Really thank you! Really Cool.

76. Major thanks for the article post. Really Cool.

77. If you would like to get a great deal from this post then you have to apply these strategies to your won blog.

78. wow, awesome article post.Much thanks again. Much obliged.

79. I appreciate you sharing this blog.Much thanks again. Will read on…

80. Awesome article post.Much thanks again. Fantastic.

81. Thank you ever so for you article post.Thanks Again. Really Great.

82. Thanks for sharing your info. I truly appreciate your efforts and I am waiting for your further
write ups thank you once again.

83. Muchos Gracias for your article post.Really looking forward to read more. Really Cool.

84. A round of applause for your blog post.Much thanks again. Really Cool.

85. This is my first time go to see at here and i am in fact impressed to read all at one place.

86. Very good article post. Great.

87. Thanks a lot for the post. Much obliged.

88. I am so grateful for your article post.Really looking forward to read more. Really Great.

89. Im thankful for the blog article.Really looking forward to read more.

90. I truly love your website.. Excellent colors & theme. Did you develop this website yourself?
Please reply back as I’m planning to create my own personal website and
want to find out where you got this from or just what the theme
is called. Kudos!

91. Really informative blog article.Really looking forward to read more. Will read on…

92. Very informative article.Really looking forward to read more. Really Cool.

93. This is really interesting, You are a very skilled blogger.
I’ve joined your feed and look forward to seeking more of your great
post. Also, I have shared your website in my social networks!

95. Thanks for the post.Really looking forward to read more. Fantastic.

96. Im obliged for the post.Thanks Again. Awesome.

97. Excellent items from you, man. I’ve take into accout your stuff previous to and you’re simply extremely
excellent. I really like what you have obtained here, certainly
like what you’re stating and the best way wherein you say it.

You make it entertaining and you still take care of to keep
it sensible. I cant wait to read far more from
you. This is actually a great website.

98. Appreciate you sharing, great blog article. Great.

99. Fantastic beat ! I wish to apprentice at the same time as you amend your web site, how can i subscribe for a weblog web site?
The account aided me a acceptable deal. I were tiny bit

100. Muchos Gracias for your blog post.Thanks Again. Much obliged.

101. Hey, thanks for the blog article.Really looking forward to read more. Want more.

102. Really enjoyed this blog article. Will read on…

103. Very good article post.Much thanks again. Fantastic.

104. Very neat blog article. Really Great.

105. I really liked your blog.Really looking forward to read more. Much obliged.

106. I value the post.Much thanks again. Fantastic.

but you seem like you know what you’re talking

108. Do you have a spam issue 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 trade solutions with others, be sure to shoot me an e-mail if interested.

109. wow, awesome blog post.Really looking forward to read more. Cool.

110. I really enjoy the blog article.Really looking forward to read more. Great.

111. Great blog article. Really Great.

112. A round of applause for your article post.Really thank you! Really Cool.

113. Very good article post. Fantastic.

114. Really enjoyed this blog.Thanks Again. Cool.

115. Very informative article post.Really looking forward to read more. Cool.

116. Im thankful for the blog article.Thanks Again. Want more.

117. Thanks for the article. Really Cool.

118. A big thank you for your article post.Really looking forward to read more. Great.

119. I am so grateful for your article.Really thank you! Much obliged.

120. Thanks a lot for the article post.Really looking forward to read more. Keep writing.

121. Hey, thanks for the article.Thanks Again. Keep writing.

122. Hey, thanks for the article.Much thanks again. Cool.

123. I was recommended this blog by means of my cousin. I’m no longer positive whether or not this
submit is written by way of him as nobody else recognize such specific approximately
my trouble. You’re amazing! Thank you!

124. Im grateful for the article.Really thank you! Will read on…

125. What’s up to all, it’s really a pleasant for me to pay a
quick visit this website, it includes important Information.

126. I am in fact grateful to the holder of this web site who has shared this great paragraph at at this place.

127. Asking questions are genuinely pleasant thing if you are not understanding something
fully, but this paragraph offers good understanding yet.

128. Looking forward to reading more. Great blog article. Want more.

129. Very informative blog post.Thanks Again. Cool.

130. I cannot thank you enough for the post.Much thanks again. Great.

131. Fantastic beat ! I wish to apprentice while you amend your site, how can i subscribe for a blog
website? The account aided me a acceptable deal. I had been a little bit acquainted of this your broadcast offered bright clear concept

133. I truly appreciate this blog.Thanks Again. Want more.

134. Thank you for your article post.Really thank you!

Regards

136. Great article post.Thanks Again. Really Cool.

137. Thanks so much for the blog.Really thank you! Great.

138. wow, awesome blog article. Really Cool.

139. Appreciate you sharing, great article post.Really looking forward to read more. Much obliged.

140. I am so grateful for your article.Thanks Again. Really Cool.

141. Oh my goodness! Impressive article dude! Thanks, However I am going through troubles with your RSS.
I don’t understand why I am unable to join it. Is there anybody having identical RSS problems?

Anyone who knows the solution can you kindly respond? Thanks!!

142. Appreciate you sharing, great article post. Great.

143. Really appreciate you sharing this blog post.Really thank you! Will read on…

144. Im thankful for the blog. Cool.

145. Thank you for the good writeup. It actually used to be a enjoyment
account it. Glance advanced to more delivered agreeable from you!
However, how can we keep in touch?

146. This is my first time visit at here and i am truly pleassant to read all at single place.

147. Thank you for your blog article. Awesome.

149. Thanks again for the post.Much thanks again. Want more.

150. I really enjoy the article post.Much thanks again. Much obliged.

151. What i do not understood is actually how you’re now not really a lot more smartly-favored than you might be now.
You are very intelligent. You realize therefore considerably with regards to this matter, produced me in my
opinion believe it from numerous numerous angles. Its like men and women don’t seem to
be fascinated except it’s one thing to do with Lady gaga!
Your individual stuffs outstanding. Always handle it up!

152. Heya just wanted to give you a brief heads up and let
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.

153. Greetings I am so glad I found your web site, I really found you by
accident, while I was researching on Bing for something else, Anyhow I am
here now and would just like to say many thanks for a incredible
post and a all round enjoyable blog (I also love the theme/design), I
don’t have time to read it all at the minute but I have
be back to read more, Please do keep up the excellent b.

154. I really like and appreciate your article post.Thanks Again. Much obliged.

155. Good site you have here.. It’s difficult to find high-quality writing
like yours nowadays. I honestly appreciate people like you!
Take care!!

156. Really enjoyed this post.Really thank you! Cool.

157. Thanks so much for the article post.Really looking forward to read more. Great.

158. Wow, great blog.Thanks Again. Really Great.

159. Im thankful for the article. Fantastic.

160. Looking forward to reading more. Great blog post.Much thanks again. Keep writing.

161. I value the post. Really Cool.

what if you wrote a catchier post title? I mean, I don’t
wish to tell you how to run your blog, however suppose you added a title that
makes people want more? I mean 【BZOJ 3103】[ONTAK2010] Palindromic Equivalence –
Qizy's Database is a little boring. You could look
open the links. You might add a video or a picture or two to get people interested about what you’ve written. In my opinion, it could bring your website a
little livelier.

163. Really informative blog post.Much thanks again. Fantastic.

164. Thank you ever so for you blog.Much thanks again. Keep writing.

165. Thanks a lot for the blog post.Thanks Again. Awesome.

166. Hello there, I found your website by means of Google while searching for
a related topic, your website came up, it looks great. I have bookmarked it in my google bookmarks.

and located that it is truly informative. I
am gonna watch out for brussels. I’ll be grateful for those who continue this in future.
Many other people shall be benefited from your writing.
Cheers!

167. Very good article post.Really thank you! Awesome.

168. Enjoyed every bit of your blog article.Much thanks again.

169. Thank you ever so for you blog post.Thanks Again. Cool.

170. Thanks-a-mundo for the article.Really looking forward to read more. Want more.

172. Hey, thanks for the post.Thanks Again. Cool.

173. Looking forward to reading more. Great article post.Really thank you! Really Great.

174. Very neat post.Much thanks again. Will read on…

175. I truly appreciate this blog article.Really thank you! Great.

176. Thanks for finally writing about >【BZOJ 3103】[ONTAK2010] Palindromic Equivalence –
Qizy’s Database <Liked it!

178. Awesome blog post.Really thank you! Want more.

179. I really enjoy the blog.Really looking forward to read more. Great.

180. Very informative post. Keep writing.

181. Really informative article. Much obliged.

182. I truly appreciate this blog article.Really thank you! Fantastic.

183. Very good blog post.Thanks Again. Awesome.

184. Great post can make continuous improvement, thanks reveal, the actual build up associated with understanding would be to maintain understanding, interest is actually the start of prosperity.

185. I really liked your article.Thanks Again.

186. I appreciate you sharing this blog.Really thank you! Really Great.

187. I loved your article post.Thanks Again. Great.

188. Thanks for sharing, this is a fantastic article. Really Cool.

189. Enjoyed every bit of your blog article.Thanks Again. Keep writing.

190. Muchos Gracias for your blog article.Really looking forward to read more. Cool.

191. I really liked your article.Really looking forward to read more. Cool.

192. Very informative blog post.Much thanks again. Fantastic.

193. I am so grateful for your post.Thanks Again. Want more.

194. I value the post. Cool.

195. I am so grateful for your article post.Much thanks again. Much obliged.

196. I think this is a real great article.Thanks Again. Want more.

197. My developer is trying to convince me to move to .net from PHP.
I have always disliked the idea because of the costs.
But he’s tryiong none the less. I’ve been using Movable-type on numerous websites for about a year and am anxious about switching to another platform.

I have heard fantastic things about blogengine.net.
Is there a way I can transfer all my wordpress content into it?
Any help would be greatly appreciated!

198. I enjoy the efforts you have put in this, thank you for all the great articles.

199. Looking forward to reading more. Great blog post. Cool.

200. Really appreciate you sharing this blog post.Really looking forward to read more. Great.

201. I cannot thank you enough for the article post.

202. Wow, great blog article.Really looking forward to read more. Want more.

203. Really enjoyed this blog.Really looking forward to read more. Much obliged.

206. Awesome blog.Really looking forward to read more. Cool.

207. Major thankies for the blog post.Really thank you! Cool.

208. A round of applause for your post.Much thanks again. Keep writing.

209. Thanks-a-mundo for the blog post.Thanks Again. Much obliged.

211. I cannot thank you enough for the post.Really thank you! Really Cool.

213. A round of applause for your article post.Much thanks again. Much obliged.

214. Im obliged for the post.Thanks Again. Want more.

215. Very informative article.Thanks Again. Really Great.

217. Looking forward to reading more. Great blog article.Thanks Again. Will read on…

218. I think this is a real great post.Much thanks again. Really Cool.

219. I loved your article post. Cool.

220. I think this is a real great article post.Really looking forward to read more. Cool.

221. Wow, great blog article.Really looking forward to read more. Much obliged.

222. Thanks so much for the blog article.Really thank you! Much obliged.

223. wow, awesome article.Really looking forward to read more. Great.

224. Thank you for your article post.Much thanks again. Will read on…

225. Say, you got a nice article. Great.