题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1693
#include<iostream> #include<cstdio> #include<cstring> #define LL long long using namespace std; const int MAXN = 5000; LL f[12][12][MAXN]; int MX,n,m,mat[12][12]; int main(){ int TT; cin>>TT; for (int T=1;T<=TT;T++) { scanf("%d%d",&m,&n); MX =1<<n+1; for (int j=1;j<=m;j++) for (int i=1;i<=n;i++) scanf("%d",&mat[i][j]),memset(f[i][j],0,sizeof(f[i][j])); if (mat[1][1]) f[1][1][3] = 1; else f[1][1][0] = 1; for (int j=1;j<=m;j++) { for (int i=1;i<n;i++) { for (int k=0;k<MX;k++) if (f[i][j][k]) { bool up=k&(1<<i+1), left=k&(1<<i); if (mat[i+1][j]) { if (up && left) f[i+1][j][k^(1<<i)^(1<<i+1)] += f[i][j][k]; else if (up || left) { f[i+1][j][k] += f[i][j][k]; f[i+1][j][k^(1<<i+1)^(1<<i)] += f[i][j][k]; } else { f[i+1][j][k^(1<<i+1)^(1<<i)] += f[i][j][k]; } } else { if (!up && !left) f[i+1][j][k] += f[i][j][k]; } } } for (int k=0;k<MX;k++) if (f[n][j][k] && (k&(1<<n)) == 0) { int up = k & 1; if (mat[1][j+1]) { if (up) { f[1][j+1][((k^1)<<1)^1] += f[n][j][k]; f[1][j+1][((k^1)<<1)^2] += f[n][j][k]; } else { f[1][j+1][(k<<1)^3] += f[n][j][k]; } } else { if (!up) f[1][j+1][k<<1] += f[n][j][k]; else continue; } } } printf("Case %d: There are %I64d ways to eat the trees.\n",T,f[n][m][0]); } return 0; }
746640 396659I enjoy searching through and I conceive this website got some truly useful stuff on it! . 353622
971814 137404Its genuinely a cool and valuable piece of info. Im glad that you merely shared this valuable data with us. Please stay us informed like this. Thank you for sharing. 249652
199694 345097Hi there! Nice post! Please do inform us when we could see a follow up! 185648
371387 48634There is clearly a great deal to know about this. I think you created various good points in functions also. 762921
813585 643057Maintain all of the articles coming. I adore reading by means of your items. Cheers. 201574
614049 876835Sweet internet web site , super pattern , quite clean and utilize friendly . 694198
Thanks for another informative site. The
place else may just I am getting that kind of information written in such a perfect means?
I have a challenge that I am simply now working on, and I have been at
the glance out for such info.
236546 778304Thanks for this amazing post! It has long been extremely useful. I wish that you will carry on posting your wisdom with us. 872012
537761 45901Wonderful blog here! Also your website loads up fast! What host are you utilizing? Can I get your affiliate link to your host? I wish my internet site loaded up as fast as yours lol 252941
114294 208380We guarantee authentic brands avoiding inferior commercial imitations, or even dangerous counterfeits. 671073
434711 174539Admiring the time and effort you put into your site and in depth information you offer. It is great to come across a blog every once in a even though that isnt the same out of date rehashed material. Excellent read! Ive saved your internet site and Im including your RSS feeds to my Google account. 755088
410428 491528Oh my goodness! a wonderful post dude. Thank you Even so I will probably be experiencing issue with ur rss . Dont know why Can not subscribe to it. Will there be any person finding identical rss difficulty? Anybody who knows kindly respond. Thnkx 283461
998362 852740very good publish, i undoubtedly adore this web website, maintain on it 799535
349791 467004if this post was likened to a flavor of yogurt, what flavor would it be? Banana, I think. 310218
Link exchange is nothing else however it is simply
placing the other person’s blog link on your
page at suitable place and other person will also do similar in favor of you.
I know this website provides quality based articles and extra material, is there any other web site which
provides these kinds of information in quality?
Hi, i think that i saw you visited my blog so i came to “return the favor”.I am
trying to find things to improve my web site!I suppose its ok to use a
few of your ideas!!
Magnificent beat ! I wish to apprentice at the same time
as you amend your website, how can i subscribe for a blog site?
The account helped me a appropriate deal. I had been tiny bit familiar of this your broadcast offered vivid transparent idea
I was suggested this web site by means of my cousin. I’m now not certain whether
this submit is written by way of him as no one else
understand such targeted approximately my difficulty. You’re amazing!
Thank you!
I’m extremely impressed with your writing talents as neatly as with the layout to your weblog.
Is this a paid theme or did you customize it yourself?
Either way keep up the nice quality writing, it’s rare to see a
great weblog like this one these days..
If you desire to improve your experience just keep
visiting this web page and be updated with the most up-to-date news update posted here.
May I just say what a comfort to uncover a person that
really knows what they are talking about on the internet.
You certainly understand how to bring a problem to light and make it important.
A lot more people have to look at this and understand this side of the story.
It’s surprising you aren’t more popular because
you definitely possess the gift.
Thanks for sharing your thoughts about coconut oil.
Regards
Rattling clean site, appreciate it for this post.
Ahaa, its nice dialogue regarding this paragraph here at this web
site, I have read all that, so at this time me
also commenting at this place.
Thanks for sharing your thoughts about sling tv. Regards
My brother recommended I might like this blog. He was entirely right.
This post actually made my day. You cann’t imagine simply how much time I had spent for this info!
Thanks!
Excellent pieces. Keep writing such kind of info on your
site. Im really impressed by your site.
Hi there, You have done an excellent job.
I will certainly digg it and personally suggest to my friends.
I am sure they will be benefited from this web site.
Hi there! This post could not be written any better! Reading this post reminds me of my old
room mate! He always kept talking about this. I will forward this post to him.
Pretty sure he will have a good read. Thanks
for sharing!
I know this if off topic but I’m looking into starting my own blog and
was curious what all is needed to get set up?
I’m assuming having a blog like yours would cost a pretty penny?
I’m not very internet savvy so I’m not 100% sure. Any recommendations or
advice would be greatly appreciated. Kudos
Every weekend i used to visit this web site, as i wish for enjoyment,
since this this web page conations actually good funny material too.
Simply desire to say your article is as amazing.
The clearness to your put up is just nice and i can suppose you’re a professional on this subject.
Well together with your permission allow me
to grasp your feed to stay updated with imminent post.
Thanks a million and please continue the rewarding work.
Generally I don’t read post on blogs, however I would like to say that this
write-up very pressured me to check out and do so!
Your writing taste has been surprised me. Thank you, quite nice post.
What’s up, yes this paragraph is really good and I have learned lot
of things from it on the topic of blogging. thanks.
We’re a group of volunteers and opening a new scheme in our community.
Your web site provided us with valuable information to work
on. You’ve done a formidable job and our entire
community will be thankful to you.
An attention-grabbing discussion is price comment. I believe that it’s best to write extra on this matter, it may not be a taboo subject but generally individuals are not enough to speak on such topics. To the next. Cheers
Im thankful for the blog post. Really Cool.
Major thankies for the article.Much thanks again. Cool.