bzoj1668 [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富
来源:互联网 发布:qt程序员常用单词 编辑:程序博客网 时间:2024/05/29 06:33
从起点开始bfs,用bfs更新dp,然后就很水了= =
#include<cstdio> #include<cstring> #include<algorithm> #define fo(i,a,b) for(int i=a;i<=b;i++) #define fd(i,a,b) for(int i=a;i>=b;i--) using namespace std; const int N=1e3+5; int map[N][N]; int f[N][N]; int n,m; const int dx[3]={-1,0,1}; const int dy[3]={1,1,1}; struct node { int x,y; }q[N*N]; bool vis[N][N]; inline void bfs(int sx,int sy) { int t=0,w=1; q[1].x=sx; q[1].y=sy; vis[sx][sy]=1; f[sx][sy]=map[sx][sy]; while (t<w) { ++t; fo(k,0,2) { int x=q[t].x+dx[k]; int y=q[t].y+dy[k]; if (x>=1&&x<=n&&y>=1&&y<=m) { f[x][y]=max(f[x][y],f[q[t].x][q[t].y]+map[x][y]); if(!vis[x][y])q[++w].x=x,q[w].y=y,vis[x][y]=1; } } } } int main() { scanf("%d%d",&n,&m); fo(i,1,n) { fo(j,1,m) scanf("%d",&map[i][j]); } bfs(1,1); printf("%d\n",f[n][m]); }
阅读全文
0 0
- bzoj1668 [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富
- bzoj1668 [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富
- bzoj1668 [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富(dp)
- 1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富
- bzoj 1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富(DP)
- [bzoj1668] Cow Pie Treasures
- [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏 记忆化搜索
- bzoj1666[Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- BZOJ 1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- BZOJ_P1666 [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏(hhhhhh)
- 1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- 【bzoj1666】 [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- bzoj1669 [Usaco2006 Oct]Hungry Cows饥饿的奶牛
- bzoj 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘
- [BZOJ1669][Usaco2006 Oct]Hungry Cows饥饿的奶牛
- 【bzoj1670】【Usaco2006 Oct】【护城河的挖掘】【凸包】
- 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘
- 【bzoj1670】[Usaco2006 Oct]Building the Moat护城河的挖掘 求凸包
- 面试题8. 旋转数组的最小数字
- python爬虫之一:requests库
- 深入学习Hibernate4_06Hibernate一对多和多对一的映射关联关系
- 宜信创始人唐宁:技术到处都是,关键看怎么用
- 那些年,我追过的绘图工具
- bzoj1668 [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富
- 关于UIView的autoresizingMask属性的研究
- KMP
- 关于线程
- C语言中的 linux 信号
- HDOJ 1068 Girls And Boys (最大独立集数)
- 消息中间件RabbitMQ 初探
- JPush极光推送Java服务器端实例
- [vim]怎样记忆 进入编辑模式的按键