题目链接

Problem Description
Zty is a man that always full of enthusiasm. He wants to solve every kind of difficulty ACM problem in the world. And he has a habit that he does not like to solve
a problem that is easy than problem he had solved. Now yifenfei give him n difficulty problems, and tell him their relative time to solve it after solving the other one.
You should help zty to find a order of solving problems to solve more difficulty problem. 
You may sure zty first solve the problem 0 by costing 0 minute. Zty always choose cost more or equal time’s problem to solve.
 
Input
The input contains multiple test cases.
Each test case include, first one integer n ( 2< n < 15).express the number of problem.
Than n lines, each line include n integer Tij ( 0<=Tij<10), the i’s row and j’s col integer Tij express after solving the problem i, will cost Tij minute to solve the problem j.
 
Output
For each test case output the maximum number of problem zty can solved

Sample Input
3
0 0 0
1 0 1
1 0 0
3
0 2 2
1 0 1
1 1 0
5
0 1 2 3 1
0 0 2 3 1
0 0 0 3 1
0 0 0 0 2
0 0 0 0 0
 
Sample Output
3
2
4
 
Hint

Hint: sample one, as we know zty always solve problem 0 by costing 0 minute.
So after solving problem 0, he can choose problem 1 and problem 2, because T01 >=0 and T02>=0.
But if zty chooses to solve problem 1, he can not solve problem 2, because T12 < T01.
So zty can choose solve the problem 2 second, than solve the problem 1.

 
题解:题目说的是zty做题目有一个奇怪的习惯,不会去做那些花费时间少于已经做过的题目所花时间的题,也就是说不会做更简单的题。在题目中,就是搜索的下一个位置的数字不能比之前的小。zty总是从第一题开始做起。
 
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
//#define LOCAL
int pro[][],maxx,n;
bool vis[];
void dfs(int p,int las,int cnt)
{
int flag=;
for(int i=; i<=n; i++)
{
if(!vis[i]&&(pro[p][i]>=las))
{
vis[i]=;
dfs(i,pro[p][i],cnt+);
vis[i]=;
flag=;
}
}
if(!flag)if(cnt>maxx)maxx=cnt;
}
int main()
{
#ifdef LOCAL
freopen("in.txt", "r", stdin);
#endif // LOCAL
//Start
while(cin>>n)
{
maxx=;
memset(pro,,sizeof pro);
memset(vis,,sizeof vis);
for(int i=; i<=n; i++)
for(int j=; j<=n; j++)
cin>>pro[i][j];
vis[]=;
dfs(,,);
printf("%d\n",maxx);
}
return ;
}

HDU 2614 Beat(DFS)的更多相关文章

  1. HDU 2614 Beat 深搜DFS

    这道题目还是比较水的,但是题意理解确实费了半天劲,没办法 谁让自己是英渣呢! 题目大意: 猪脚要解决问题, 他有个习惯,每次只解决比之前解决过的问题的难度要大. 他给我们一个矩阵  矩阵的 i 行 j ...

  2. DFS HDOJ 2614 Beat

    题目传送门 /* 题意:处理完i问题后去处理j问题,要满足a[i][j] <= a[j][k],问最多能有多少问题可以解决 DFS简单题:以每次处理的问题作为过程(即行数),最多能解决n个问题, ...

  3. HDU.5692 Snacks ( DFS序 线段树维护最大值 )

    HDU.5692 Snacks ( DFS序 线段树维护最大值 ) 题意分析 给出一颗树,节点标号为0-n,每个节点有一定权值,并且规定0号为根节点.有两种操作:操作一为询问,给出一个节点x,求从0号 ...

  4. HDU - 2614 dfs

    思路:记录当前用的最大时间即刚解决的问题花费的时间,下一个应该做的题的时间必须大于等于刚才的. AC代码 #include <cstdio> #include <cmath> ...

  5. hdu 5727 Necklace dfs+二分图匹配

    Necklace/center> 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5727 Description SJX has 2*N mag ...

  6. hdu 4499 Cannon dfs

    Cannon Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4499 D ...

  7. hdu 1175 连连看 DFS

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1175 解题思路:从出发点开始DFS.出发点与终点中间只能通过0相连,或者直接相连,判断能否找出这样的路 ...

  8. HDU 5547 Sudoku(DFS)

    题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=5547 题目: Sudoku Time Limit: 3000/1000 MS (Java/Others ...

  9. F - Auxiliary Set HDU - 5927 (dfs判断lca)

    题目链接: F - Auxiliary Set HDU - 5927 学习网址:https://blog.csdn.net/yiqzq/article/details/81952369题目大意一棵节点 ...

随机推荐

  1. NOIP2014-提高组初赛C语言解析(选择填空题)

    第二十届全国青少年信息学奥林匹克联赛初赛 一.单项选择题(共 20 题,每题 1.5 分,共计 30 分.每题有且仅有一个正确选项) 1. 以下哪个是面向对象的高级语言( B ) A.汇编语言   B ...

  2. mac生成ssh keys

    打开终端 输入ssh-keygen,然后系统提示输入文件保存位置等信息,连续敲三次回车即可,生成的SSH key文件保存在中-/.ssh/id_rsa.pub

  3. JQUERY 轮播插件

    闲来无事,写个轮播插件,项目中用到的时候就无需在写了,不然会累死宝宝的 废话少说 代码上 html部分 <div class="lunbo"> <ul> & ...

  4. 用border做一个移动端常见的返回按钮

    第一步 .hs1{ float: left; .mt(.25rem); .ml(.12rem); width: .3rem; height: .3rem; border-top: 2px solid ...

  5. 特殊函数(__all__)

    python里__all__ 属性分别于模块和包之中的用法 一. 在模块(*.py)中使用意为导出__all__列表里的类.函数.变量等成员,否则将导出modualA中所有不以下划线开头(私有)的成员 ...

  6. net之session漫谈及分布式session解决方案

    最近一直在纠结net下分布式会话的实现,现将近日来的个人感想记录如下,如果有什么更好的解决方案请指教. 1.什么是session: Session 对象存储特定用户会话所需的属性及配置信息.这样,当用 ...

  7. JAVA内容回顾(二)——面向对象(OOP)

    1.类与对象 类:类指的是同种对象的抽象,看不见摸不着的.包含有属性与方法. 对象:是类的具体实现,看的见摸得着的东西. 类是对象的抽象,对象是类的具体实现. 2.访问修饰符 public:在项目的任 ...

  8. C#调用托管C++类(DLL)

    毕设是做一个网络摄像头的相关应用.界面用WPF,图像处理部分是OpenCV.没用EmguCV的原因是国内EmguCV的资料相对比较少,EmguCV虽然提供了Winform的控件,在做UI上有一定优势, ...

  9. CSS3之动画Animation特效

    CSS3的出现 让我们通过css样式也能写出炫酷的特效 通过 Animation 这个属性 无需插件和jquery也可以轻松的完成简单的动画效果 DEMO: <!DOCTYPE html> ...

  10. javascript 日期对象

    1.日期对象定义 var Udate=new Date();//获得当前日期 2.Date对象中处理时间和日期的常用方法: 3.返回/设置年份 var mydate=new Date();//当前时间 ...