HDU 2614 Beat
来源:互联网 发布:网络安全技术与应用 编辑:程序博客网 时间:2024/06/05 02:54
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2614
Beat
Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 874 Accepted Submission(s): 546
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.
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.
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
30 0 01 0 11 0 030 2 21 0 11 1 050 1 2 3 10 0 2 3 10 0 0 3 10 0 0 0 20 0 0 0 0
下面是AC代码:题意:T[i][j]表示处理完i问题后,处理j问题需要的时间,但是如果我处理了i问题,现在处理j问题,那么如果我再处理k问题的要求是必须T[i][j]>=T[j][k]搜索一遍即可
#include<iostream>using namespace std;const int maxn=16;int Map[maxn][maxn],vis[maxn],n,ans;void dfs(int now,int len,int v){ ans=max(ans,len); for(int i=1;i<n;i++) { if(!vis[i]&&Map[now][i]>=v) { vis[i]=1; dfs(i,len+1,Map[now][i]); vis[i]=0; } }}int main(){ while(cin>>n) { for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>Map[i][j]; fill(vis,vis+maxn,0); ans=0; vis[0]=1; for(int i=1;i<n;i++) { vis[i]=1; dfs(i,2,Map[0][i]); vis[i]=0; } cout<<ans<<endl; } return 0;}
0 0
- hdu(2614) Beat
- HDU 2614 Beat (dfs)
- hdu 2614 Beat
- HDU 2614 Beat
- hdu 2614 Beat
- HDU 2614 Beat
- hdu 2614 beat
- HDU 2614 Beat (DFS)
- hdu 2614 Beat
- HDU 2614 Beat
- HDU - 2614 Beat
- HDU:2614 beat
- 杭电 hdu 2614 Beat
- 【DFS】 HDU 2614 Beat 水
- HDU 2614 Beat(dfs)
- HDU 2614 Beat (DFS)
- HDU 2614 Beat(DFS)
- HDU 2614 Beat(dfs)
- Apache MultiViews!!!
- 各种位运算技巧
- 在windows 7 64bit下编译Hadoop 2.6.0源码
- python核心模块——urllib模块
- 字符与字节及字符流与字节流的区别
- HDU 2614 Beat
- jQuery.artDialog用法(弹窗)
- 卡特兰数
- seajs的动态压缩
- javascript基础笔记一函数
- [部署篇8]VMWare搭建Openstack——计算节点的Neutron安装
- 20150411C++文件流
- 如何获取Spinner里item的值
- Objective-c NSPathUtilities.h常用路径工具、函数和方法