Luogu P3120 [USACO15FEB]牛跳房子(金)Cow Hopscotch (Gold)
这是一道典型的记忆化搜索题。
f[x][y]表示以x,y为右下角的方案数。
code:
#include <cstdio>
#define mod 1000000007
using namespace std;
int n,m,k,a[][],f[][];
int DP(int x,int y){
if(f[x][y])return f[x][y];
for(int i=;i<x;i++)
for(int j=;j<y;j++)
if(a[i][j]!=a[x][y])f[x][y]+=DP(i,j),f[x][y]%=mod;
return f[x][y];
}
int main(){
scanf("%d %d %d\n",&n,&m,&k);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)scanf("%d",&a[i][j]);
f[][]=;
printf("%d",DP(n,m));
return ;
}
Luogu P3120 [USACO15FEB]牛跳房子(金)Cow Hopscotch (Gold)的更多相关文章
- 洛谷 P3120 [USACO15FEB]牛跳房子(金)Cow Hopscotch (Gold)
P3120 [USACO15FEB]牛跳房子(金)Cow Hopscotch (Gold) 就像人类喜欢跳格子游戏一样,FJ的奶牛们发明了一种新的跳格子游戏.虽然这种接近一吨的笨拙的动物玩跳格子游戏几 ...
- 洛谷P3120 [USACO15FEB]牛跳房子(动态开节点线段树)
题意 题目链接 Sol \(f[i][j]\)表示前\(i\)行\(j\)列的贡献,转移的时候枚举从哪里转移而来,复杂度\(O(n^4)\) 然后考虑每一行的贡献,动态开节点线段树维护一下每种颜色的答 ...
- Luogu P3033 [USACO11NOV]牛的障碍Cow Steeplechase(二分图匹配)
P3033 [USACO11NOV]牛的障碍Cow Steeplechase 题意 题目描述 --+------- -----+----- ---+--- | | | | --+-----+--+- ...
- Luogu P2966 [USACO09DEC]牛收费路径Cow Toll Paths
题目描述 Like everyone else, FJ is always thinking up ways to increase his revenue. To this end, he has ...
- 【洛谷】2990:[USACO10OPEN]牛跳房子Cow Hopscotch【单调队列优化DP】
P2990 [USACO10OPEN]牛跳房子Cow Hopscotch 题目描述 The cows have reverted to their childhood and are playing ...
- 洛谷P3120 [USACO15FEB]Cow Hopscotch
题目描述 Just like humans enjoy playing the game of Hopscotch, Farmer John's cows have invented ...
- P2870 [USACO07DEC]最佳牛线,黄金Best Cow Line, Gold
P2870 [USACO07DEC]最佳牛线,黄金Best Cow Line, Gold我比赛的时候A了,luogu上25分,QAQ,又憨又傻的200+代码,我为什么要干电脑干的事情,无语了.如果左边 ...
- 洛谷——P1821 [USACO07FEB]银牛派对Silver Cow Party
P1821 [USACO07FEB]银牛派对Silver Cow Party 题目描述 One cow from each of N farms (1 ≤ N ≤ 1000) conveniently ...
- Cow Hopscotch
Cow Hopscotch 题目描述 Just like humans enjoy playing the game of Hopscotch, Farmer John's cows have inv ...
随机推荐
- 使用jMeter构造逻辑上有依赖关系的一系列并发请求
相信前端开发工程师对CSRF(Cross-site request forgery)跨站请求伪造这个概念都非常熟悉,有的时候也简写成XSRF,是一种对网站的恶意利用. 尽管听起来像跨站脚本(XSS), ...
- call/apply
call与apply都可以改变this指向,但是传参列表不同. call 任何一种方法都可以.call,借用别人函数,自己用. call只需把实参按照形参的个数传进去,apply只能传一个argume ...
- The transaction log for database 'XXX' is full due to 'ACTIVE_TRANSACTION'.
Msg 9002, Level 17, State 4, Line 4The transaction log for database 'Test' is full due to 'ACTIVE_TR ...
- Centos6 Ngnix和fastcgi搭建
一.下载Nginx 依赖pcre,zlib,openssl 下载解压包,解压后进入 ./configue make make install 默认安装到/usr/local/ngnix 可执行文件在/ ...
- VC++和C语言中常见数据类型转换为字符串的方法
1.短整型(int) itoa(i,temp,10);///将i转换为字符串放入temp中,最后一个数字表示十进制 itoa(i,temp,2); ///按二进制方式转换 2.长整型(long) lt ...
- 【题解】洛谷P1967 [NOIP2013TG] 货车运输(LCA+kruscal重构树)
洛谷P1967:https://www.luogu.org/problemnew/show/P1967 思路 感觉2013年D1T3并不是非常难 但是蒟蒻还是WA了一次 从题目描述中看出每个点之间有许 ...
- android中OpenMax的实现【3】OMX中主要成员
原文 http://blog.csdn.net/tx3344/article/details/8117908 通过上文知道了,每个AwesomePlayer 只有一个OMX服务的入口,但是Awesom ...
- Excel批量导入商品,遇到导入失败记录到另一个Excel中供下载查看
/// <summary> /// EXCEL批量导入 /// </summary> /// <param name="filePath">文件 ...
- WPF引用ActiveX提示没有注册类或不是有效的Win32程序
VS2017开发WPF时,需要引用UKey组件读取插入的Ukey编号和密钥 该组件在网页端调用时使用ObjectId进行ActiveX注册即可,后来做成WPF客户端进行读取遇到该问题. 解决: 右键项 ...
- Vue.js与 ASP.NET Core 服务端渲染功能整合
http://mgyongyosi.com/2016/Vuejs-server-side-rendering-with-aspnet-core/ 原作者:Mihály Gyöngyösi 译者:oop ...