Codeforces 348 D - Turtles Lindström–Gessel–Viennot lemma


#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head const int N = 3e3 + ;
const int MOD = 1e9 + ;
int dp[N][N], n, m;
char s[N][N];
int solve(int a, int b, int c, int d) {
for (int i = ; i <= n; ++i) for (int j = ; j <= m; ++j) dp[i][j] = ;
for (int i = a; i <= c; ++i) {
for (int j = b; j <= d; ++j) {
if(i == a && j == b) {
if(s[i][j] == '.') dp[i][j] = ;
}
else {
if(s[i][j] == '.') dp[i][j] = (dp[i-][j]+dp[i][j-])%MOD;
}
}
}
return dp[c][d];
}
int main() {
scanf("%d %d", &n, &m);
for (int i = ; i <= n; ++i) scanf("%s", s[i]+);
printf("%lld\n", (solve(, , n-, m)*1LL*solve(, , n, m-) - solve(, , n, m-)*1LL*solve(, , n-, m)%MOD+MOD)%MOD);
return ;
}
Codeforces 348 D - Turtles Lindström–Gessel–Viennot lemma的更多相关文章
- 牛客网多校训练第一场 A - Monotonic Matrix(Lindström–Gessel–Viennot lemma)
链接: https://www.nowcoder.com/acm/contest/139/A 题意: 求满足以下条件的n*m矩阵A的数量模(1e9+7):A(i,j) ∈ {0,1,2}, 1≤i≤n ...
- Nowcoder Monotonic Matrix ( Lindström–Gessel–Viennot lemma 定理 )
题目链接 题意 : 在一个 n * m 的矩阵中放置 {0, 1, 2} 这三个数字.要求 每个元素 A(i, j) <= A(i+1, j) && A(i, j) <= ...
- Lindström–Gessel–Viennot lemma定理 行列式板子
https://blog.csdn.net/qq_37025443/article/details/86537261 博客 下面是wiki上的讲解,建议耐心地看一遍...虽然看了可能还是不懂 http ...
- Lindström–Gessel–Viennot lemma
解决不相交路径计数 有两个大小为N的点集A,B A上每一个点对应着B的每一个点 求满足条件的路径集合有多少个 图里面可能还有一些障碍 Codeforces 348 D 有一个N*M的网格图 有两个点 ...
- LGV 算法 (Lindström–Gessel–Viennot lemma)
e(ai,bi)为从起点ai到终点bi的方案数.以上矩阵行列式结果就是(a1,a2,...an) 到 (b1,b2,...bn) 的所有不相交路径的种数. 具体证明的话看wiki,比较长.. 这个定理 ...
- Lindström–Gessel–Viennot lemma 应用两则
对于一张无边权的DAG图,给定n个起点和对应的n个终点,这n条不相交路径的方案数为 det() (该矩阵的行列式) 其中e(a,b)为图上a到b的方案数 codeforces 348D [给定一张n* ...
- 排列组合( Lindström–Gessel–Viennot lemma 定理)
链接:https://www.nowcoder.com/acm/contest/139/A来源:牛客网 Monotonic Matrix 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ ...
- Codeforces 348 D - Turtles
D - Turtles 思路: LGV 定理 (Lindström–Gessel–Viennot lemma) 从{\(a_1\),\(a_2\),...,\(a_n\)} 到 {\(b_1\),\( ...
- LGV定理 (CodeForces 348 D Turtles)/(牛客暑期多校第一场A Monotonic Matrix)
又是一个看起来神奇无比的东东,证明是不可能证明的,这辈子不可能看懂的,知道怎么用就行了,具体看wikihttps://en.wikipedia.org/wiki/Lindstr%C3%B6m%E2%8 ...
随机推荐
- pandas对时间列分组求diff遇到的问题
例子: df = pd.DataFrame() df['A'] = [1, 1, 2] df['B'] = [datetime.date(2018, 1, 2), datetime.date(2018 ...
- zero copy图解
原文链接:https://www.jianshu.com/p/8c6b056f73ce 1 传统的IO读写 传统的IO读写有两种方式:IO终端和DMA.他们各自的原理如下. 1.1 IO中断原理 ...
- 守护进程daemon
# -*- coding: utf-8 -*- import sys, os, time, atexit from signal import SIGTERM class Daemon: def __ ...
- js实现限制容器中字符个数
html: <div class="ellipsis"> 夜空中最亮的星/请指引我走出去/夜空中最亮的星 是否知道/那曾与我同心的身影 如今在哪里/夜空中最亮的星 是否 ...
- [转帖]TPC-C解析系列03_TPC-C基准测试之SQL优化
TPC-C解析系列03_TPC-C基准测试之SQL优化 http://www.itpub.net/2019/10/08/3330/ TPC-C是一个非常严苛的基准测试模型,考验的是一个完备的关系数据库 ...
- (零)linux 学习 -- 从 shell 开始
The Linux Command Line 读书笔记 - 部分内容来自 http://billie66.github.io/TLCL/book/chap02.html 文章目录 前言 什么是 she ...
- RS232标准与TTL/COM小常识
1.TTL电平标准 输出 L: <0.8V : H:>2.4V. 输入 L: <1.2V : H:>2.0V 2.CMOS电平标准 输出 L: <0.1*Vcc : H: ...
- Python重要配置大全
PYTHON 环境安装 安装虚拟环境 pip install virtualenv 卸载包是用:pip uninstall virtualenv 快捷下载安装可用豆瓣源,方法为: pip instal ...
- Springboot模板(thymeleaf、freemarker模板)
目的: 1.thymeleaf模板 2.Freemarker模板 thymeleaf模板 thymeleaf 的优点: 支持html5标准,页面无须部署到servlet开发到服务器上,直接通过浏览器就 ...
- (转) 嵌入式 Linux 利用 udev 实现自动检测挂载U盘
本文链接:https://blog.csdn.net/cfl927096306/article/details/95180940 udev配置文件是/etc/udev/udev.conf,也许长这样: ...