dp , dp[ i ][ j ] = max( dp[ k ][ j - 1 ] ) + G[ i ][ j ] ( i - 1 <= k <= i + 1 , dp[ k ][ j - 1 ] > 0 ) 一开始没注意到要 dp[ k ][ j - 1 ] > 0 才能取 , 然后就WA 了2次... -------------------------------------------------------------------------- #include<cs…
Description 最近,奶牛们热衷于把金币包在面粉里,然后把它们烤成馅饼.第i块馅饼中含有Ni(1<=Ni<=25)块金币,并且,这个数字被醒目地标记在馅饼表面. 奶牛们把所有烤好的馅饼在草地上排成了一个R行(1<=R<=100)C列(1<=C<=100)的矩阵.你现在站在坐标为(1,1)的馅饼边上,当然,你可以拿到那块馅饼里的所有金币.你必须从现在的位置,走到草地的另一边,在坐标为(R,C)的馅饼旁边停止走动.每做一次移动,你必须走到下一列的某块馅饼旁边,并且,…
c[x][y]为从(x,y)到(n,m)的最大值,记忆化一下 有个剪枝是因为y只能+1所以当n-x>m-y时就算x也一直+1也是走不到(n,m)的,直接返回0即可 #include<iostream> #include<cstdio> using namespace std; const int N=105,dx[]={-1,0,1}; int n,m,a[N][N],c[N][N]; int read() { int r=0,f=1; char p=getchar(); w…
1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富 Time Limit: 3 Sec  Memory Limit: 64 MBSubmit: 498  Solved: 289[Submit][Status] Description 最近,奶牛们热衷于把金币包在面粉里,然后把它们烤成馅饼.第i块馅饼中含有Ni(1<=Ni<=25)块金币,并且,这个数字被醒目地标记在馅饼表面. 奶牛们把所有烤好的馅饼在草地上排成了一个R行(1<=R<=100)…
http://www.lydsy.com/JudgeOnline/problem.php?id=1668 裸dp.. f[i][j]表示i行j列最大能拿到 f[i][j]=max(f[i+1][j-1], f[i-1][j-1], f[i][j-1])+a[i][j] 当f[i+1][j-1], f[i-1][j-1], f[i][j-1]均不为0时 #include <cstdio> #include <cstring> #include <cmath> #inclu…
1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富 Time Limit: 3 Sec  Memory Limit: 64 MBSubmit: 459  Solved: 268[Submit][Status] Description 最近,奶牛们热衷于把金币包在面粉里,然后把它们烤成馅饼.第i块馅饼中含有Ni(1<=Ni<=25)块金币,并且,这个数字被醒目地标记在馅饼表面. 奶牛们把所有烤好的馅饼在草地上排成了一个R行(1<=R<=100)…
1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 554  Solved: 346[Submit][Status][Discuss] Description The cows are having a picnic! Each of Farmer John's K (1 <= K <= 100) cows is grazing in one of N (1 <= N <…
有点类似背包 , 就是那样子搞... ------------------------------------------------------------------------------------ #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #define rep( i , n ) for( int i = 0 ;  i < n ; ++i…
裸的LIS ----------------------------------------------------------------- #include<cstdio> #include<cstring> #include<algorithm> #include<iostream>   #define rep( i , n ) for( int i = 0 ;  i < n ; ++i ) #define clr( x , c ) memset…
直接从每个奶牛所在的farm dfs , 然后算一下.. ---------------------------------------------------------------------------------------- #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #include<vector>   #define rep( i…