#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 105;
const int mod = 1e+9;
namespace mat {
int a[N][N];
int n,p=1;
int Gauss() {
int ans = 1;
for(int i = 1; i < n; i ++) {
for(int j = i + 1; j < n; j ++)
while(a[j][i]) {
int t = a[i][i] / a[j][i];
for(int k = i; k < n; k ++)
a[i][k] = (a[i][k] - t * a[j][k] + mod) % mod;
swap(a[i], a[j]);
ans = - ans;
}
ans = (ans * a[i][i]) % mod;
}
return (ans + mod) % mod;
}
} // namespace mat int a[N][N],d[N][N],b[N][N],c[N][N],n,m,ind;
char str[N]; int id(int i,int j) {
return c[i][j];
} int add(int p,int q) {
a[p][q]=a[q][p]=1;
d[p][p]++;
d[q][q]++;
} signed main() {
ios::sync_with_stdio(false);
cin>>n>>m;
for(int i=1; i<=n; i++) {
cin>>str+1;
for(int j=1; j<=m; j++) {
if(str[j]=='.') b[i][j]=0, c[i][j]=++ind;
else b[i][j]=1;
}
}
for(int i=1; i<=n; i++) {
for(int j=1; j<=m; j++) {
if(b[i][j]==0) {
if(i<n && b[i+1][j]==0) add(id(i,j),id(i+1,j));
if(j<m && b[i][j+1]==0) add(id(i,j),id(i,j+1));
}
}
}
mat::n=ind;
for(int i=1; i<=ind; i++) {
for(int j=1; j<=ind; j++) {
mat::a[i][j]=d[i][j]-a[i][j];
}
}
cout<<mat::Gauss()<<endl;
}

[HEOI2015] 小Z的房间 - 矩阵树定理的更多相关文章

  1. 【bzoj4031】[HEOI2015]小Z的房间 矩阵树定理

    题目描述 你突然有了一个大房子,房子里面有一些房间.事实上,你的房子可以看做是一个包含n*m个格子的格状矩形,每个格子是一个房间或者是一个柱子.在一开始的时候,相邻的格子之间都有墙隔着. 你想要打通一 ...

  2. bzoj4031 [HEOI2015]小Z的房间——矩阵树定理

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4031 矩阵树定理的模板题(第一次的矩阵树定理~): 有点细节,放在注释里了. 代码如下: # ...

  3. [HEOI2015]小Z的房间(矩阵树定理学习笔记)

    题目描述 你突然有了一个大房子,房子里面有一些房间.事实上,你的房子可以看做是一个包含n*m个格子的格状矩形,每个格子是一个房间或者是一个柱子.在一开始的时候,相邻的格子之间都有墙隔着. 你想要打通一 ...

  4. BZOJ 4031: [HEOI2015]小Z的房间 [矩阵树定理 行列式取模]

    http://www.lydsy.com/JudgeOnline/problem.php?id=4031 裸题........ 问题在于模数是$10^9$ 我们发现消元的目的是让一个地方为0 辗转相除 ...

  5. BZOJ 4031: [HEOI2015]小Z的房间 (矩阵树定理 板题)

    背结论 : 度-邻 CODE1 O(n3logn)O(n^3logn)O(n3logn) #include <bits/stdc++.h> using namespace std; typ ...

  6. bzoj 4031: 小Z的房间 矩阵树定理

    bzoj 4031: 小Z的房间 矩阵树定理 题目: 你突然有了一个大房子,房子里面有一些房间.事实上,你的房子可以看做是一个包含n*m个格子的格状矩形,每个格子是一个房间或者是一个柱子.在一开始的时 ...

  7. LG4111/LOJ2122 「HEOI2015」小Z的房间 矩阵树定理

    问题描述 LG4111 题解 矩阵树定理板子题. \(\mathrm{Code}\) #include<bits/stdc++.h> using namespace std; #defin ...

  8. BZOJ.4031.[HEOI2015]小Z的房间(Matrix Tree定理 辗转相除)

    题目链接 辗转相除解行列式的具体实现? 行列式的基本性质. //864kb 64ms //裸的Matrix Tree定理.练习一下用辗转相除解行列式.(因为模数不是质数,所以不能直接乘逆元来高斯消元. ...

  9. BZOJ 4031 [HEOI2015]小Z的房间(Matrix-Tree定理)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=4031 [题目大意] 你突然有了一个大房子,房子里面有一些房间. 事实上,你的房子可以看 ...

随机推荐

  1. gRPC搭建使用方式

    gRpc 官网  链接 新建服务端项目 在服务端内先编写一个 .proto 文件 greet.proto syntax = "proto3"; service Greeter { ...

  2. C++中用vector定义矩阵

    熟悉c风格的矩阵定义,那么用纯c++特性vector如何定义一个矩阵呢? # include<vector> # include <iostream> int main() { ...

  3. 本地连接mysql的url写法

    一.jdbc:mysql:///中三条斜杠(///) 第三个/代表什么? jdbc:mysql:///testdatabase等同于 jdbc:mysql://localhost:3306/testd ...

  4. 【pattern】设计模式(2) - 模版方法模式

    前言 一晃一年又过了,还是一样的渣. 一晃2周又过去了,还是没有坚持写博客. 本来前2天说填一下SQL注入攻击的坑,结果看下去发现还是ojdbc.jar中的代码,看不懂啊.这坑暂时填不动,强迫在元旦最 ...

  5. puthon 字典的 .update() 方法

    1.可以直接更新字典 2.也可以用等号连接,更新一个可迭代对象.

  6. PAT (Advanced Level) Practice 1055 The World's Richest (25 分) (结构体排序)

    Forbes magazine publishes every year its list of billionaires based on the annual ranking of the wor ...

  7. Django models 关联(一对多,多对多,一对一)

    参考:https://blog.csdn.net/houyanhua1/article/details/84953388

  8. ELK学习实验015:日志的自定义index配置

    前面使用json格式收集了nginx的日志,但是再index的显示是filebeat-*,现在使用自定义的index进行配置 但是再使用filebeat的7.4版本以后,有一个巨坑,就是按照网络的很多 ...

  9. php 文件追加写入

    //追加写入 file_put_contents('xml.text',json_encode($postObj,JSON_FORCE_OBJECT).PHP_EOL,FILE_APPEND);

  10. maven通过pom文件下载相关依赖包的网址

    下载有关依赖插件的网址去MVNREPOSITORY仓库寻找对应的版本然后添加到pom文件中就可以自动下载了 网址为:https://mvnrepository.com