【BZOJ 4031】[HEOI2015] 小Z的房间

题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4031

仍然是裸的矩阵树

#include<iostream>
#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;

const LL MAXN = 100;
const LL MOD = 1000000000;

LL G[MAXN][MAXN],n,m,num[MAXN][MAXN],cnt;
char pat[MAXN];

inline int Gauss(){
	for (LL j=1;j<=n;j++) for (LL i=1;i<=n;i++) 
		G[i][j] = (G[i][j]%MOD + MOD) % MOD;
	LL ret = 1;
	for (LL j=1;j<=n;j++) {
		for (LL k=j+1;k<=n;k++) while (G[j][k]) {
			LL t = G[j][j] / G[j][k];
			for (LL i=1;i<=n;i++) G[i][j] = ((G[i][j] - G[i][k]*t) % MOD + MOD) % MOD;
			for (LL i=1;i<=n;i++) swap(G[i][j], G[i][k]); ret *= -1; ret = (ret%MOD + MOD) % MOD;
		} 
		ret = (G[j][j]*ret%MOD + MOD) % MOD;
	} return ret; 
}

inline void AddEdge(LL u, LL v){
	G[u][u]++; G[v][v]++; 
	G[u][v]--; G[v][u]--;
}

int main(){
	scanf("%d%d",&m,&n);
	for (LL j=1;j<=m;j++) {
		scanf("%s",pat+1);
		for (LL i=1;i<=n;i++) if (pat[i] == '.') {
			num[i][j] = ++cnt;
			if (num[i-1][j]) AddEdge(num[i][j],num[i-1][j]);
			if (num[i][j-1]) AddEdge(num[i][j],num[i][j-1]);
		}
	} n = cnt-1; printf("%d\n",Gauss());
	return 0;
}

25 thoughts to “【BZOJ 4031】[HEOI2015] 小Z的房间”

  1. I absolutely love your blog and find nearly all of your post’s to be what precisely I’m
    looking for. can you offer guest writers to write content for you?
    I wouldn’t mind writing a post or elaborating on a lot of
    the subjects you write about here. Again, awesome web site!

  2. When I initially commented I seem to have clicked the -Notify
    me when new comments are added- checkbox and now whenever a comment is added I
    receive 4 emails with the exact same comment. Perhaps there is a means you are able to remove
    me from that service? Many thanks!

  3. Fantastic website. Lots of helpful info here.

    I’m sending it to some friends ans additionally
    sharing in delicious. And certainly, thanks on your effort!

  4. My coder 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 WordPress on several websites for about a year and am worried about switching to another platform.
    I have heard fantastic things about blogengine.net.
    Is there a way I can import all my wordpress content into it?
    Any help would be really appreciated!

  5. I was more than happy to uncover this great site.
    I want to to thank you for ones time just for this wonderful read!!
    I definitely loved every bit of it and I have you bookmarked to see new
    information in your site.

  6. Today, while I was at work, my cousin stole my iphone
    and tested to see if it can survive a thirty foot drop, just so she
    can be a youtube sensation. My apple ipad is now broken and she has 83 views.

    I know this is totally off topic but I had to share it with someone!

  7. I’ve been exploring for a bit for any high-quality articles or weblog posts
    on this sort of space . Exploring in Yahoo I at last stumbled upon this web site.
    Studying this info So i’m happy to express that I’ve an incredibly just right uncanny feeling I found out just what I needed.
    I such a lot surely will make sure to don?t overlook this web
    site and give it a look regularly.

  8. Howdy just wanted to give you a quick 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 internet browsers and both show the same outcome.

  9. We’re a group of volunteers and starting a new scheme in our community. Your site offered us with valuable info to work on. You have done a formidable job and our whole community will be grateful to you.

  10. Hi there just wanted to give you a brief heads up and let you know a few of the images aren’t loading correctly.

    I’m not sure why but I think its a linking issue. I’ve tried it in two different web browsers and both
    show the same results.

  11. Hey just wanted to give you a brief heads up and let you know a few of the images
    aren’t loading properly. 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.

  12. I simply could not depart your web site prior to suggesting that I actually loved
    the standard information an individual provide in your
    guests? Is going to be back steadily in order to investigate cross-check new posts

  13. Wow! This blog looks just like my old one!

    It’s on a totally different topic but it has pretty much the same page layout and design. Excellent choice of colors!

  14. Thank you for the good writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! By the way, how could we communicate?

  15. My goal here is to link the wordpress blog entries to a frame in a personal site. So I want only the blog entries to appear, but none of the menu bars or other things associated with wordpress only what was posted. I know wordpress is done in PHP so i was wondering if anybody knew the specifics of the coding and how I would go about doing this.. . Thanks!.

Leave a Reply

Your email address will not be published. Required fields are marked *