codevs 1267 老鼠的旅行 DP 解题报告
来源:互联网 发布:真才美网络学校 编辑:程序博客网 时间:2024/05/01 11:13
题目描述 Description
You are a mouse that lives in a cage in a large laboratory.
你是一只生活在笼子里的实验室老鼠。
The laboratory is composed of one rectangular grid of square cages, with a total of R rows and C columns of cages (1 ≤ R,C ≤ 25).
实验室是一个R行C列的格子矩阵(1 ≤ R,C ≤ 25). 每个格子是一个笼子. (尼玛还要我活么……)
To get your exercise, the laboratory owners allow you to move between cages.
为了让你锻炼身体,实验室管理员允许你在笼子之间移动。
You can move between cages either by moving right between two adjacent cages in the same row, or by moving down between two adjacent cages in the same column.
你只能向右和向下移动。
You cannot move diagonally, left or up.
你不能斜着移动,也不能向上和向左移动。
Your cage is in one corner of the laboratory, which has the label (1,1) (to indicate top-most row, left-most column).
你所在的笼子是实验室的左上角,标记为(1,1)
You would like to visit your brother who lives in the cage labelled (R,C) (bottom-most row, right-most column), which is in the other corner diagonally.
你想去右下角的笼子(R,C)里找你的女朋友(尼玛老鼠也有女盆友么!!!)
However, there are some cages which you cannot pass through, since they contain cats.
但是有一些笼子是不能经过的,因为里面有猫(谁说老鼠怕猫么,还有,管理员有毛病么……)
Your brother, who loves numbers, would like to know how many different paths there are between your cage and his that do not pass through any cat cage. Write a program to compute this number of cat-free paths.
你女朋友很爱数学,她想要知道有多少条不同的路径可以从你的笼子到达她的笼子。写一个程序来计算吧。(这样的女朋友不要也罢……)
输入描述 Input Description
The first line of input contains two integers R and C, separated by one space representing the number of rows and columns (respectively). On the second line of input is the integer K, the number of cages that contain cats. The next K lines each contain the row and column positions (in that order) for a cage that contains a cat. None of the K cat cages are repeated, and all cages are valid positions. Note also that (1,1) and (R,C) will not be cat cages.
第一行包含2个整数R和C,第二行一个整数K,代表包含猫的笼子的个数,接下来K行包含K个不同的位置信息,代表K个包含猫的笼子的位置信息,注意(1,1)和(R,C)这两个位置是不会有猫的, 否则出题者就没法活了……
输出描述 Output Description
Output the non-negative integer value representing the number of paths between your cage at position (1,1) and your brother’s cage at position (R,C). You can assume the output will be strictly less than 1 000 000 000.
输出一个非负整数代表你可以去你女朋友笼子里和她啪啪啪的路径数目,你可以假设这个输出会严格小于1,000,000,000。
样例输入 Sample Input
样例输入 1:
2 3
1
2 1
样例输入 2:
3 4
3
2 3
2 1
1 4
样例输出 Sample Output
样例输出 1:
2
样例输出 2:
1
思路
神TM翻译。。。
小小DP,lialia说是搜索题。。。不知道吧,可以搜索一下?
代码
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<cmath>#include<vector>using namespace std;const int N=100+5;int n,m,q,map[N][N],dp[N][N];int main(){ scanf("%d%d%d",&n,&m,&q); for (int i=1;i<=q;i++) { int x,y; scanf("%d%d",&x,&y); map[x][y]=-1; } for (int i=2;i<=m+n;i++) { dp[1][1]=1; for (int k=i+1;k>0;k--) if (map[k][i+1-k]>=0) dp[k][i+1-k]=dp[k-1][i+1-k]+dp[k][i-k]; } printf("%d\n",dp[n][m]); return 0;}
- codevs 1267 老鼠的旅行 DP 解题报告
- CodeVS1267 老鼠的旅行 解题报告【棋盘型DP】
- Codevs 1267老鼠的旅行
- Codevs 1267老鼠的旅行
- codevs动态规划 老鼠的旅行
- codevs 1380 没有上司的舞会 DP 解题报告
- codevs 1253 超级市场 DP 解题报告
- codevs 1219 骑士游历 DP 解题报告
- codevs 2622 数字序列 DP 解题报告
- codevs 1620 轮船问题 DP 解题报告
- CodeVS 3657 区间DP 解题报告
- 一个人的旅行 解题报告
- 【日常学习】【棋盘DP】codevs1267 老鼠的旅行题解
- HDU2066 一个人的旅行 解题报告--Dijkstra
- 【codevs1045】 奶牛的旅行 解题报告
- Codevs 1503 愚蠢的宠物 解题报告
- Codevs 1026 逃跑的拉尔夫 解题报告
- codevs 1047 邮票面值设计 DFS+DP 解题报告
- Java 加密算法实现方案 DES / 3DES / AES / Base64
- Mysql 升级重装后连接出错 Table \'performance_schema.session_variables\' doesn\'t exist
- 剑指offer_字符串---左旋转字符串
- PHP 安装扩展步骤
- vsphere 客户机 使用光驱引导启动
- codevs 1267 老鼠的旅行 DP 解题报告
- php 安装扩展插件实例-gd库
- java基础篇(五:面向对象——1)接口和抽象类
- Centos 7 主要命令改动 service chkconfig iptables
- php插件名称 yum安装
- U盘模式无法引导进入pe系统
- 修改 ssh 远程连接 时间
- tomcat 安装在 linux
- tomcat 简单配置