poj1088 dfs
来源:互联网 发布:php数据表统计插件 编辑:程序博客网 时间:2024/06/06 00:50
好吧发现大部分题解都是动态规划。。
也对,最长递减子序列嘛,其实我觉得我现在简直相当于不会动态规划的样子。。
搜索也很裸,,
#include<stdio.h>#include<iostream>#define max 110using namespace std;int map[max][max],sum,r,c;int po[4][2]={{1,0},{0,1},{-1,0},{0,-1}};struct node{ int value,step;}node[110][110];int ok(int x,int y){ if(x<0||x>=r||y<0||y>=c)return 0;else return 1;}void dfs(int x,int y){ int a,b; int step=node[x][y].step; int value=node[x][y].value; for(int i=0;i<4;i++) { a=x+po[i][0]; b=y+po[i][1]; if(ok(a,b)&&node[a][b].value>value&&node[a][b].step<step+1) { node[a][b].step=step+1; dfs(a,b); } }}int main(){ while(scanf("%d%d",&r,&c)!=EOF) { for(int i=0;i<r;i++) for(int j=0;j<c;j++) { cin>>node[i][j].value; node[i][j].step=1; } for(int i=0;i<r;i++) for(int j=0;j<c;j++) { if(node[i][j].step==1) dfs(i,j); else continue; } int maxx=-1; for(int i=0;i<r;i++){for(int j=0;j<c;j++){if(node[i][j].step>maxx)maxx=node[i][j].step;}} printf("%d\n",maxx); } return 0;}
0 0
- poj1088 dfs
- poj1088 DFS深度搜索
- poj1088滑雪搜索dfs
- poj1088(dfs||dp)
- poj1088 滑雪(dfs)
- poj1088 滑雪 DP+DFS
- dfs(深度优先搜素)poj1088
- poj1088 滑雪(dfs、dp优化)
- poj1088滑雪(dfs+记忆化搜索、备忘录)
- poj1088滑雪【dfs or 记忆化搜索】
- POJ1088 滑雪(动态规划+深搜DFS)
- DFS:POJ1088-滑雪(记忆化搜索)
- poj1088滑雪(记忆化dfs)
- POJ1088
- poj1088
- POJ1088
- POJ1088
- Poj1088
- VS2010 创建和调用动态链接库
- HiPhone的Sciphone I9规格全回顾与
- HTML5 - 不是专为商务应用
- jsp 实现验证码功能
- Bmtron游戏类型
- poj1088 dfs
- PHP 分页类的实现
- 策略模式
- Apache服务器使用的Java servlet的实现
- Aurigma图片上传程序是为您的网站的图片上传解决方案
- HTML初学----图像
- POJ 1260--Pearls
- 从瀑布模型、极限编程到敏捷开发
- BETA记录桥梁PHP和Java之间的差距