题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1004
数据传送门:http://pan.baidu.com/s/1jIc0r5s
这个题目,最开始无脑暴力,结果T到死 QAQ
总之就是Polya上不了,就只能上Burnside
然后直接求不动点也要T,于是只能搞三维背包
详见:hzwer.com/3222.html
#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int MAXN = 21; const int N = 61; const int SGZ = 3; int f[MAXN][MAXN][MAXN],p,col[MAXN],n,m,vout,tot,cnt[N],to[N],vis[N]; inline void Get_CIR(){ tot = 0; memset(vis,0,sizeof(vis)); for (int i=1;i<=n;i++) scanf("%d",&to[i]); for (int i=1;i<=n;i++) if (!vis[i]) { cnt[++tot] = 0; for (int w=i;!vis[w];w=to[w]) cnt[tot]++, vis[w] = 1; } } inline void DP(){ memset(f,0,sizeof(f)); f[0][0][0] = 1; for (int t=1,w=cnt[1];t<=tot;w=cnt[++t]) for (int i=col[1];~i;i--) for (int j=col[2];~j;j--) for (int k=col[3];~k;k--) if (f[i][j][k]){ if (i + w <= col[1]) f[i+w][j][k] += f[i][j][k], f[i+w][j][k] %= p; if (j + w <= col[2]) f[i][j+w][k] += f[i][j][k], f[i][j+w][k] %= p; if (k + w <= col[3]) f[i][j][k+w] += f[i][j][k], f[i][j][k+w] %= p; } vout += f[col[1]][col[2]][col[3]]; vout %= p; } inline int pow(int w, int t){ int ret = 1; while (t) { if (t & 1) ret = ret*w % p; t >>= 1; w = w*w % p; } return ret; } inline int read(){ char c=getchar(); int ret = 0; while (c<'0'||c>'9') c=getchar(); while (c<='9'&&c>='0') ret=ret*10+c-'0',c=getchar(); return ret; } int main(){ for (int i=1;i<=SGZ;i++) n += (col[i] = read()); m = read(), p = read(); for (tot=1;tot<=n;tot++) cnt[tot] = 1; tot--; DP(); for (int i=1;i<=m;i++) Get_CIR(), DP(); printf("%d\n",vout*pow(m+1,p-2)%p); return 0; }
Thanks-a-mundo for the blog article.Really looking forward to read more. Much obliged.
A round of applause for your blog post.Really looking forward to read more.
I really liked your post. Cool.
Thanks-a-mundo for the blog.Really thank you! Cool.
Thank you for your post.Much thanks again. Really Cool.
Very good blog post.Much thanks again.
Im thankful for the blog.Thanks Again. Great.
Hello There. I discovered your blog the usage of msn. This is a
very smartly written article. I’ll make sure to bookmark it
and return to read extra of your useful information.
Thanks for the post. I will definitely comeback.
Hi! Someone in my Facebook group shared this site with us so I came to take a look.
I’m definitely loving the information. I’m bookmarking and will be tweeting this to my followers!
Terrific blog and superb style and design.
Great beat ! I wish to apprentice while you amend your site, how can i subscribe for a blog web site?
The account aided me a acceptable deal. I had been a little bit acquainted of
this your broadcast provided bright clear concept
Good site you have got here.. It’s difficult to find high-quality writing like yours nowadays.
I truly appreciate people like you! Take care!!
Hello it’s me, I am also visiting this website regularly,
this site is truly pleasant and the visitors are in fact sharing pleasant thoughts.
These are actually impressive ideas in regarding blogging.
You have touched some nice things here. Any way keep up wrinting.
What’s up mates, how is all, and what you wish for to say concerning
this article, in my view its actually amazing in support of me.
Nice post. I was checking continuously this blog and I’m impressed!
Very helpful info specially the last part :
) I care for such info a lot. I was seeking this certain information for a very long time.
Thank you and good luck.
Muchos Gracias for your article. Much obliged.
Thanks for ones marvelous posting! I genuinely enjoyed reading
it, you can be a great author.I will remember to bookmark your blog and definitely will come
back later on. I want to encourage yourself to continue
your great job, have a nice morning!
I loved your article.Thanks Again. Much obliged.
When someone writes an article he/she maintains the thought of a
user in his/her brain that how a user can be aware of it.
So that’s why this post is amazing. Thanks!
Im obliged for the article post. Will read on…
Good web site you’ve got here.. It’s difficult to find excellent writing
like yours nowadays. I really appreciate individuals like you!
Take care!!
Hi! Do you know if they make any plugins to protect against hackers?
I’m kinda paranoid about losing everything I’ve worked hard on. Any tips?
Fantastic article.Thanks Again. Fantastic.
Amazing! This blog looks exactly like my old one!
It’s on a completely different topic but it has pretty much the same
layout and design. Excellent choice of colors!
Incredible points. Solid arguments. Keep up the good
effort.
Have you ever thought about adding a little bit more than just
your articles? I mean, what you say is valuable and all. But
think of if you added some great visuals or videos to give your posts more, “pop”!
Your content is excellent but with pics and videos, this website could definitely be one of the most beneficial in its niche.
Fantastic blog!
I really enjoy the post.Much thanks again. Keep writing.
Thanks so much for the blog. Fantastic.
Asking questions are really good thing if you are not understanding
anything entirely, but this post presents pleasant understanding even.
I really liked your article post.Thanks Again.
Link exchange is nothing else but it is simply placing the other person’s webpage link on your page at appropriate place and
other person will also do same in support of
you.
Looking forward to reading more. Great blog.Thanks Again. Fantastic.
I loved your article.Thanks Again. Cool.
Thanks for sharing excellent informations. Your website is very cool. I’m impressed by the details that you have on this website. It reveals how nicely you perceive this subject. Bookmarked this website page, will come back for extra articles. You, my friend, ROCK! I found just the info I already searched all over the place and simply could not come across. What a perfect website.
Looking forward to reading more. Great article.Really looking forward to read more. Fantastic.
I always spent my half an hour to read this webpage’s posts everyday along with a mug
of coffee.
Thanks-a-mundo for the blog post. Much obliged.
I really liked your blog post.Much thanks again. Keep writing.
Very good article post.Much thanks again. Want more.
Muchos Gracias for your blog post.Really looking forward to read more. Much obliged.
Appreciate you sharing, great article post.Thanks Again. Will read on…
Hey, thanks for the blog. Awesome.
Thanks so much for the blog post. Will read on…
Very informative blog article.Thanks Again. Fantastic.
Thanks so much for the blog.Much thanks again. Really Great.
Thank you for your blog post.Really looking forward to read more. Great.
I am so grateful for your article post.Much thanks again. Keep writing.
Thank you for your blog article.Thanks Again.
I enjoy what you guys are up too. This kind of clever work and exposure!
Keep up the very good works guys I’ve added you guys to my own blogroll.
I visited several blogs however the audio feature for audio songs current at this web site is truly excellent.
I really enjoy the blog article.Really thank you! Awesome.
Say, you got a nice article post.Really looking forward to read more. Keep writing.
Very good post.Really thank you!
It is the best time to make some plans for the future and it’s
time to be happy. I’ve read this post and if I could I wish to suggest you some interesting things or tips.
Perhaps you could write next articles referring to this article.
I desire to read even more things about it!
Major thankies for the blog post.Thanks Again.
Very good blog article.Really thank you! Great.
I truly appreciate this blog article.Much thanks again. Fantastic.
Muchos Gracias for your blog article.Much thanks again. Awesome.
Thank you ever so for you blog.Really thank you! Much obliged.
Wonderful blog! I found it while surfing around on Yahoo News.
Do you have any suggestions on how to get listed in Yahoo News?
I’ve been trying for a while but I never seem to get there!
Thanks
fantastic issues altogether, you simply gained a brand new reader.
What might you suggest in regards to your publish that you made a
few days ago? Any sure?
Thanks-a-mundo for the blog.Really looking forward to read more. Great.
I think this is a real great article post.Really looking forward to read more.
Enjoyed every bit of your article post.Really looking forward to read more. Keep writing.
Thanks a lot for the article.Really thank you! Great.
Hello There. I discovered your weblog the usage of msn. That
is a really neatly written article. I will make sure to bookmark it and return to learn extra of your useful information. Thank you for the post.
I will certainly return.
A round of applause for your article post.Really thank you! Cool.
Very good article.Really looking forward to read more. Awesome.
If you are going for most excellent contents
like I do, simply go to see this site every day because it presents quality
contents, thanks
I really liked your blog post.Much thanks again. Awesome.
naturally like your website however you need to take a look at
the spelling on several of your posts. Several
of them are rife with spelling issues and I find it very bothersome to tell
the truth however I’ll definitely come again again.
Muchos Gracias for your blog article.Much thanks again. Much obliged.
Great blog. Awesome.
Good blog you’ve got here.. It’s difficult to find
high-quality writing like yours nowadays. I honestly appreciate people like you!
Take care!!
Very good blog.Really looking forward to read more. Cool.
Thanks so much for the article.Much thanks again. Fantastic.
Thanks again for the blog.Really thank you!
Fantastic blog.Really thank you! Cool.
Wow, this post is pleasant, my sister is analyzing these things, therefore I am going
to inform her.
Thanks for the blog article.Really looking forward to read more. Great.
In fact no matter if someone doesn’t understand after that its
up to other users that they will help, so here it
occurs.
Perfect piece of work you have done, this web site is really cool with fantastic information.
I loved your blog.Really thank you! Really Cool.
Thank you ever so for you article post.Thanks Again. Will read on…
Really informative article.Really looking forward to read more. Want more.