【弱省胡策】Round #0 【Flower Dance】
来源:互联网 发布:linux mysql 远程访问 编辑:程序博客网 时间:2024/06/04 23:36
求有坏点的网格图的从左上角到右下角不相交的两条路径的个数。
先求出所有方案减去相交的方案。
对于相交方案,将最后一个交点后两人的路径互换。
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <cmath>#define Rep(i, x, y) for (int i = x; i <= y; i ++)#define Dwn(i, x, y) for (int i = x; i >= y; i --)#define RepE(i, x) for(int i = pos[x]; i; i = g[i].nex)using namespace std;typedef long long LL;const int N = 2005, mod = 1000000007;int n, m, f[N][N];char s[N][N];LL Calc(int x, int y, int x2, int y2) {if (s[x][y] == '1') return 0;memset(f, 0, sizeof(f));f[x][y] = 1;Rep(i, x, x2) {Rep(j, y, y2) if ((i != x || j != y) && s[i][j] != '1') {f[i][j] = (f[i - 1][j] + f[i][j - 1]) % mod;}}return f[x2][y2];}int main(){scanf ("%d%d", &n, &m);Rep(i, 1, n) {scanf ("%s", s[i] + 1);}LL ans = Calc(1, 2, n - 1, m) * Calc(2, 1, n, m - 1) % mod - Calc(1, 2, n, m - 1) * Calc(2, 1, n - 1, m) % mod + mod;cout << ans % mod << endl; return 0;}
0 0
- 【弱省胡策】Round #0 【Flower Dance】
- Flower
- flower?
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) D. Little Artem and Dance
- Problem C. Jane's Flower Shop Google APAC 2017 University Test Round A
- Round A APAC Test 2017 Problem C. Jane's Flower Shop 二分、高精度要求
- 2031 - Dance Dance Revolution
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque(思维 贪心)
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque 贪心
- Flower.c
- sun Flower
- Flower garden
- tc flower
- JOLIN -- Dance
- Pole dance
- Dance Snakes
- Dance Dance Revolution----UVAlive_2031----DP
- 江尤理:8月7非农前瞻,或许这次可以威风一次
- 任务调度(四)——ScheduledExecutorService替代Timer,实现多线程任务调度
- Java用dom4j将list<? extends Map<String,String>>结果集数据导出成xml文件
- 二级指针的使用
- SRTM + Global Mapper + Arcgis
- 【弱省胡策】Round #0 【Flower Dance】
- HDOJ 题目3695 Computer Virus on Planet Pandora(AC自动机)
- Volley的Get、Post方式(JsonObjectRequest、StringRequest)以及Volley获取图片的3种方式
- js运动框架完美运动框架2--这个才有效
- flash音乐重复播放的问题
- 国外优秀的数据库实用工具介绍
- 解决Linux下cocos2dx找不到头文件Box2D的问题
- tlv 格式解析
- mysql分表和表分区详解