A9263 | Turtles
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You've got a table of size $n×m$ . We'll consider the table rows numbered from top to bottom 1 through $n$ , and the columns numbered from left to right 1 through $m$ . Then we'll denote the cell in row $x$ and column $y$ as $(x,y)$ .
Initially cell $(1,1)$ contains two similar turtles. Both turtles want to get to cell $(n,m)$ . Some cells of the table have obstacles but it is guaranteed that there aren't any obstacles in the upper left and lower right corner. A turtle (one or the other) can go from cell $(x,y)$ to one of two cells $(x+1,y)$ and $(x,y+1)$ , as long as the required cell doesn't contain an obstacle. The turtles have had an argument so they don't want to have any chance of meeting each other along the way. Help them find the number of ways in which they can go from cell $(1,1)$ to cell $(n,m)$ .
More formally, find the number of pairs of non-intersecting ways from cell $(1,1)$ to cell $(n,m)$ modulo $1000000007$ $(10^{9}+7)$ . Two ways are called non-intersecting if they have exactly two common points — the starting point and the final point.
Initially cell $(1,1)$ contains two similar turtles. Both turtles want to get to cell $(n,m)$ . Some cells of the table have obstacles but it is guaranteed that there aren't any obstacles in the upper left and lower right corner. A turtle (one or the other) can go from cell $(x,y)$ to one of two cells $(x+1,y)$ and $(x,y+1)$ , as long as the required cell doesn't contain an obstacle. The turtles have had an argument so they don't want to have any chance of meeting each other along the way. Help them find the number of ways in which they can go from cell $(1,1)$ to cell $(n,m)$ .
More formally, find the number of pairs of non-intersecting ways from cell $(1,1)$ to cell $(n,m)$ modulo $1000000007$ $(10^{9}+7)$ . Two ways are called non-intersecting if they have exactly two common points — the starting point and the final point.
输入格式
The first line contains two integers $n,m$ $(2<=n,m<=3000)$ . Each of the following $n$ lines contains $m$ characters describing the table. The empty cells are marked by characters ".", the cells with obstacles are marked by "\#".
It is guaranteed that the upper left and the lower right cells are empty.
It is guaranteed that the upper left and the lower right cells are empty.
输出格式
In a single line print a single integer — the number of pairs of non-intersecting paths from cell $(1,1)$ to cell $(n,m)$ modulo $1000000007$ $(10^{9}+7)$ .
输入输出样例
输入 #1
4 5 ..... .###. .###. .....
输出 #1
1
输入 #2
2 3 ... ...
输出 #2
1
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted