2016 Multi-University Training Contest 1 G. Rigid Frameworks
Rigid Frameworks
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 337 Accepted Submission(s): 273
Maid xiaodao is learning theoretical computer science in her spare time, and recently she was fascinated by Professor Erik Demaine's Geometric Folding Algorithms - Linkages, Origami, Polyhedra. The following problem was inspired by this book.
Recall that a graph is a collection of vertices and edges connecting the vertices, and that two vertices connected by an edge are called adjacent. Graphs can be embedded in Euclidean space by associating each vertex with a point in the Euclidean space.
⋅ A flexible graph is an embedding of a graph where it is possible to move one or more vertices continuously so that the distance between at least two nonadjacent vertices is altered while the distances between each pair of adjacent vertices is kept constant.
⋅ A rigid graph is an embedding of a graph which is not flexible. Informally, a graph is rigid if by replacing the vertices with fully rotating hinges and the edges with rods that are unbending and inelastic, no parts of the graph can be moved independently from the rest of the graph.

Sit down and relax, to simplify the problem, let's only consider the planar graphs as grids. The grid graphs embedded in the Euclidean plane are not rigid, as the following animation demonstrates:

However, one can make them rigid by adding diagonal edges to the cells. For example, the following picture shows a 2 × 3 grid graph.

Note that you can add at most one orientation of a diagonal edge in one single cell. In fact, there are 448 ways to make a 2 × 3 grid graph rigid. And now we want to know, how many different rigid m × n grid graph with diagonal edges in total? Dear contestant, could you please find it out?
3 2
7 9
10 10
448
357533852
935300639
题意:
一个n*m的网格,如题目中图片所示。
所有的点都是交接点,所有的直线都是不可拉伸的铁棍。
这样这个网格是可以活动的。
现在可以在某些网格中在对角线上添加不可拉伸的铁棍。
同一个网格只能添加一次。
这样添加完后,若网格个不可活动,则为稳定。 问,使网格稳定的添边方式有多少种?
题解:
首先,要知道:
1、每一列水平的直线之间是平行的,每一行竖直的直线之间也是平行的。
2、题目要求的稳定,就是要求横着的直线和竖着的直线都垂直。
这里的直线是那一条条小线段,下文中的小直线、直线都是一个意思。 如果我在第(i,j)个格子添加了斜线,
那么第i行的小直线和第j列小直线就必然垂直了。 所以如果我把这n个行作为左边的点,m个列作为右边的点。
添加对角线使它们垂直就相当于在对应点对之间连一条边。
注意这种垂直关系是可以传递的。 所以问题转换成了,是一个左边n个点,右边m个点的二分图,
有多少种方式连边使它们连通。
其中每个点对的连边方式有两种(主对角线、副对角线) 那么这个方式怎么统计?
若是随意连边,总方案数为3^(n*m)种。
因为n*m对边可以连,也可以不连,连有两种,不连一种。 考虑二分图不连通的方案数:
那么至少左边1号点所在的连通快不会包含所有点。 所以只需要枚举1号点所在的连通快大小,
计算出当1号点所在连通块大小为所枚举的时候的方案数就可以了。
枚举时可以枚举1号点所在连通块左边有i个点,右边有j个点。
那么连边方案数就为f[i][j],恰好是个子问题。 所以若令f[n][m]为左边n个点,右边m个点的二分图的连通方案数。
f[n][m] = 3^(n*m) -
sigma(0<=i<n, sigma(0<=j<=m,
f[i + 1][j] * C(n - 1, i) * C(m, j) * 3^( (n-1-i)*(m-j) )
))
const int N = , MOD = 1e9 + ;
int n, m, f[N][N], all[N * N], C[N][N]; inline int add(int x, int y) {
return (((x + y) % MOD) + MOD) % MOD;
} inline int mul(int x, int y) {
return (((x * 1ll * y) % MOD) + MOD) % MOD;
} inline void init() {
all[] = ;
for(int i = ; i < * ; ++i) all[i] = mul(all[i - ], ); for(int i = ; i < N; ++i) C[i][] = ;
for(int i = ; i < N; ++i)
for(int j = ; j < N; ++j)
C[i][j] = add(C[i - ][j - ], C[i - ][j]); for(int n = ; n <= ; ++n)
for(int m = ; m <= ; ++m) {
f[n][m] = all[n * m];
for(int lef = ; lef < n; ++lef)
for(int rig = ; rig <= m; ++rig) {
if(lef == n - && rig == m) continue;
f[n][m] = add(f[n][m],
-mul(mul(mul(C[n - ][lef], C[m][rig]),
f[lef + ][rig]),
all[(n - lef - ) * (m - rig)]));
}
}
} int main() {
init();
while(scanf("%d%d", &n, &m) == ) printf("%d\n", f[n][m]);
return ;
}
2016 Multi-University Training Contest 1 G. Rigid Frameworks的更多相关文章
- 2016 Al-Baath University Training Camp Contest-1 G
Description The forces of evil are about to disappear since our hero is now on top on the tower of e ...
- 2016 Al-Baath University Training Camp Contest-1
2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...
- 2016 Al-Baath University Training Camp Contest-1 E
Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be th ...
- 2016 Al-Baath University Training Camp Contest-1 F
Description Zaid has two words, a of length between 4 and 1000 and b of length 4 exactly. The word a ...
- 2016 Al-Baath University Training Camp Contest-1 A
Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...
- [CFGym101028] 2016 Al-Baath University Training Camp Contest-1
比赛链接:http://codeforces.com/gym/101028/ 由于实习,几乎没有时间刷题了.今天下午得空,断断续续做了这一套题,挺简单的. A.读完题就能出结果. /* ━━━━━┒ギ ...
- 2016 Al-Baath University Training Camp Contest-1 J
Description X is fighting beasts in the forest, in order to have a better chance to survive he's gon ...
- 2016 Al-Baath University Training Camp Contest-1 I
Description It is raining again! Youssef really forgot that there is a chance of rain in March, so h ...
- 2016 Al-Baath University Training Camp Contest-1 H
Description You've possibly heard about 'The Endless River'. However, if not, we are introducing it ...
随机推荐
- 如何删除已安装的Windows服务
1) 开始-运行,输入regedit命令. (Windows键+R,输入regdeit) 2) 回车后会弹出一个窗口:注册编辑器.找到 HKEY_LOCAL_MACHINE\SYSTEM\Curre ...
- CentOS光盘挂载命令以及安装软件
最近又学习了一个命令:mount 挂载命令,我们在安装软件的时候,直接敲命令install 包名,但是这里其实是联网安装的, 如果使用光盘,从本地安装就要使用mount命令. 1.我的linux系统是 ...
- 分页查询和分页缓存查询,List<Map<String, Object>>遍历和Map遍历
分页查询 String sql = "返回所有符合条件记录的待分页SQL语句"; int start = (page - 1) * limit + 1; int end = pag ...
- python的反转(切片)
看下面代码吧,简单来说不如直接看代码.如下: #coding=utf-8 __author__ = 'debude' a = 'python' print a[::-1] #从最后n开始,每走一位都打 ...
- KRPano资源分析工具使用说明(KRPano XML/JS解密 切片图批量下载 球面图还原 加密混淆JS还原美化)
软件交流群:571171251(软件免费版本在群内提供) krpano技术交流群:551278936(软件免费版本在群内提供) 最新博客地址:blog.turenlong.com 限时下载地址:htt ...
- java 使用正则表达式过滤HTML中标签
/** * 去掉文本中的html标签 * * @param inputString * @return */ public static String html2Text(String inputSt ...
- 循环冗余码crc
待编码的有效信息组多项式:M(x) 生成多项式(产生校验码的多项式):G(x) 余数多项式:R(x) 商:Q(x) 生成多项式是四次的,所以某个多项式除以生成多项式的余式肯定是三次的,所以要加四位00 ...
- [Sass]不同样式风格的输出方法
[Sass]不同样式风格的输出方法 众所周知,每个人编写的 CSS 样式风格都不一样,有的喜欢将所有样式代码都写在同一行,而有的喜欢将样式分行书写.在 Sass 中编译出来的样式风格也可以按不同的样式 ...
- 小众Tox——大众的“去中心化”聊天软件
★Tox是什么 一个反窥探的开源项目:一种基于DHT(BitTorrent)技术的即时通讯协议:一个为安全而生的加密通讯系统 .美国棱镜计划曝光后,一个名为 irungentoo 的牛人于17天后的2 ...
- react开发环境搭建
---恢复内容开始--- 要想用react,需要安装: 1)babel-sublime: 作用:编译es6,支持ES6, React.js, jsx代码高亮,并对所编译的代码进行高亮显示. 安装步骤: ...