HDU 2614 Beat(DFS)
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.
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.
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.
#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)的更多相关文章
- HDU 2614 Beat 深搜DFS
这道题目还是比较水的,但是题意理解确实费了半天劲,没办法 谁让自己是英渣呢! 题目大意: 猪脚要解决问题, 他有个习惯,每次只解决比之前解决过的问题的难度要大. 他给我们一个矩阵 矩阵的 i 行 j ...
- DFS HDOJ 2614 Beat
题目传送门 /* 题意:处理完i问题后去处理j问题,要满足a[i][j] <= a[j][k],问最多能有多少问题可以解决 DFS简单题:以每次处理的问题作为过程(即行数),最多能解决n个问题, ...
- HDU.5692 Snacks ( DFS序 线段树维护最大值 )
HDU.5692 Snacks ( DFS序 线段树维护最大值 ) 题意分析 给出一颗树,节点标号为0-n,每个节点有一定权值,并且规定0号为根节点.有两种操作:操作一为询问,给出一个节点x,求从0号 ...
- HDU - 2614 dfs
思路:记录当前用的最大时间即刚解决的问题花费的时间,下一个应该做的题的时间必须大于等于刚才的. AC代码 #include <cstdio> #include <cmath> ...
- hdu 5727 Necklace dfs+二分图匹配
Necklace/center> 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5727 Description SJX has 2*N mag ...
- hdu 4499 Cannon dfs
Cannon Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4499 D ...
- hdu 1175 连连看 DFS
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1175 解题思路:从出发点开始DFS.出发点与终点中间只能通过0相连,或者直接相连,判断能否找出这样的路 ...
- HDU 5547 Sudoku(DFS)
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=5547 题目: Sudoku Time Limit: 3000/1000 MS (Java/Others ...
- F - Auxiliary Set HDU - 5927 (dfs判断lca)
题目链接: F - Auxiliary Set HDU - 5927 学习网址:https://blog.csdn.net/yiqzq/article/details/81952369题目大意一棵节点 ...
随机推荐
- hdu 1536 S-Nim (简单sg函数)
题意:首先输入K 表示一个集合的大小 之后输入集合 表示对于这对石子只能去这个集合中的元素的个数 之后输入 一个m 表示接下来对于这个集合要进行m次询问 之后m行 每行输入一个n 表示有n个堆 每 ...
- 网络爬虫之定向爬虫:爬取当当网2015年图书销售排行榜信息(Crawler)
做了个爬虫,爬取当当网--2015年图书销售排行榜 TOP500 爬取的基本思想是:通过浏览网页,列出你所想要获取的信息,然后通过浏览网页的源码和检查(这里用的是chrome)来获相关信息的节点,最后 ...
- GIT 代码管理工具 SourceTree
什么是git? git是一款开源的分布式版本控制工具 在世界上所有的分布式版本控制工具中,git是最快.最简单.最流行的 git的起源 作者是Linux之父:Linus Benedict Torval ...
- fiddler还是浏览器的问题
当我在浏览器里输入http://localhost/infomanage/price?cityid=1&cateid=246&timer=3 后端接收的参数是timer的时候,浏览器会 ...
- Makefile.am编写规则
概念 Makefile.am是比Makefile更高层次的规则只需要指定要生成什么目标,依赖于什么文件,和要安装到什么目录.automake会根据Makefile.am来自动生成Makefile.in ...
- Exchange 2010 实用小技巧
#Exchange安装必须开启防火墙服务 #批量建用户: for /f "tokens=1,2,3,4,5,6,7 delims=," %a in (c:\users.csv) ...
- Mp3tag(MP3文件信息修改器) V2.79a 多语绿色版
软件名称: Mp3tag(MP3文件信息修改器) 软件语言: 多国语言 授权方式: 免费软件 运行环境: Win 32位/64位 软件大小: 3.0MB 图片预览: 软件简介: Mp3Tag 是一款m ...
- 人工手动冷备不完全恢复介绍(purge表不完全恢复)
不完全恢复不完全恢复的基本类型:1)基于时间点 (until time): 使整个数据库恢复到过去的一个时间点前2)基于scn (until change): 使整个数据库恢复到过去的某个SCN前3) ...
- CSS样式类型
CSS样式可以写在哪些地方呢?从CSS 样式代码插入的形式来看基本可以分为以下3种:内联式.嵌入式和外部式三种.这一小节先来讲解内联式 (一)内联式样式 内联式css样式表就是把css代码直接写在现有 ...
- odoo 获取当前会计年度
odoo 获取当前会计年度 def default_fiscal_year(self): current_period = self.env['account.fiscalyear'].find() ...