题目传送门

这是一道典型的记忆化搜索题。

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)的更多相关文章

  1. 洛谷 P3120 [USACO15FEB]牛跳房子(金)Cow Hopscotch (Gold)

    P3120 [USACO15FEB]牛跳房子(金)Cow Hopscotch (Gold) 就像人类喜欢跳格子游戏一样,FJ的奶牛们发明了一种新的跳格子游戏.虽然这种接近一吨的笨拙的动物玩跳格子游戏几 ...

  2. 洛谷P3120 [USACO15FEB]牛跳房子(动态开节点线段树)

    题意 题目链接 Sol \(f[i][j]\)表示前\(i\)行\(j\)列的贡献,转移的时候枚举从哪里转移而来,复杂度\(O(n^4)\) 然后考虑每一行的贡献,动态开节点线段树维护一下每种颜色的答 ...

  3. Luogu P3033 [USACO11NOV]牛的障碍Cow Steeplechase(二分图匹配)

    P3033 [USACO11NOV]牛的障碍Cow Steeplechase 题意 题目描述 --+------- -----+----- ---+--- | | | | --+-----+--+- ...

  4. Luogu P2966 [USACO09DEC]牛收费路径Cow Toll Paths

    题目描述 Like everyone else, FJ is always thinking up ways to increase his revenue. To this end, he has ...

  5. 【洛谷】2990:[USACO10OPEN]牛跳房子Cow Hopscotch【单调队列优化DP】

    P2990 [USACO10OPEN]牛跳房子Cow Hopscotch 题目描述 The cows have reverted to their childhood and are playing ...

  6. 洛谷P3120 [USACO15FEB]Cow Hopscotch

    题目描述 Just like humans enjoy playing the game of Hopscotch, Farmer John&apos;s cows have invented ...

  7. P2870 [USACO07DEC]最佳牛线,黄金Best Cow Line, Gold

    P2870 [USACO07DEC]最佳牛线,黄金Best Cow Line, Gold我比赛的时候A了,luogu上25分,QAQ,又憨又傻的200+代码,我为什么要干电脑干的事情,无语了.如果左边 ...

  8. 洛谷——P1821 [USACO07FEB]银牛派对Silver Cow Party

    P1821 [USACO07FEB]银牛派对Silver Cow Party 题目描述 One cow from each of N farms (1 ≤ N ≤ 1000) conveniently ...

  9. Cow Hopscotch

    Cow Hopscotch 题目描述 Just like humans enjoy playing the game of Hopscotch, Farmer John's cows have inv ...

随机推荐

  1. CentOS下go 安装

     go 语言源码安装依赖 ,gcc ,make glibc库,等,上述工具安装省略,另外,其源代码更新采用的是mercurial 工具,安装前先安装mercureal :   1.mercurial安 ...

  2. 闲来无事,用javascript写了一个简单的轨迹动画

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. tp3.2上一篇下一篇功能

    1. 后台 //上一页 $map1['a_id'] = array('gt',$a_id); $map1['cate_id'] = array('eq',$cate_id); $front=$arc- ...

  4. CVPR 2016 paper reading (3)

    DeepFashion: Powering Robust Clothes Recognition and Retrieval with Rich Annotations, Ziwei Liu, Pin ...

  5. python -- @classmethod @staticmethod区别和使用

    python中的定义: class MyClass: ... @classmethod  # classmethod的修饰符 def class_method(cls, arg1, arg2, ... ...

  6. ICT测试点是干什么的, 怎么设置!

    简单理解:ICT类似如万用表,只是把表笔换成了测试针.那么问题就简单了,一颗普通的RLC元件,都必须有两个测试点才能够测试,当然同一个网络共用的节点用一个测试点就可以了. 详细描述: PCB设计时要看 ...

  7. springboot集成activiti工作流时容易出现的问题

    No.1 启动报错 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'or ...

  8. 【Oracle】Oracle安装配置、创建数据库实例及用户和连接

    https://blog.csdn.net/wudiyong22/article/details/78904361 参考资料:https://www.cnblogs.com/hoobey/p/6010 ...

  9. javascript中sort()排序的一些理解

    sort()方法对一个数组进行排序,并可以接受一个比较函数,最后返回一个排序的数组. 1.sort()有自身默认的比较函数,该函数把排序的元素都看作字符串. var s = [5, 4, 3, 2, ...

  10. MAMP:MySQL wasn't able to start

    MAMP 我点击start server的时候 发现mysql服务器打不开 http://images.cnblogs.com/cnblogs_com/lwwen/1231721/o_11111111 ...