博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 2614 Beat【深搜】
阅读量:6759 次
发布时间:2019-06-26

本文共 1774 字,大约阅读时间需要 5 分钟。

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
题意:
给出N道题目,从0开始做,每做一题之后只能做耗时更多的题目,找出最多能做多少道题目;
分析:采用回溯的方法遍历每一种情况,找出其中做题最多的一个做题路线。
code:
View Code
#include
#include
int p[16][16]; int c[16]; int max; int n; void dfs(int row,int now,int tot) {
int i; int flag=1; c[row]=1; for(i=0;i
=now&&!c[i]) flag=0; if(flag) {
if(max
=now&&!c[i]) dfs(i,p[row][i],tot+1); c[row]=0; //深搜过程中清除标记 } int main() {
int i,j,tot; while(scanf("%d",&n)!=EOF) {
memset(c,0,sizeof(c)); for(i=0;i
 

转载于:https://www.cnblogs.com/dream-wind/archive/2012/03/15/2397842.html

你可能感兴趣的文章
Oracle系列:安装Oracle RAC数据库(二)
查看>>
nginx 另一WAF方式
查看>>
LinkedTransferQueue学习导引
查看>>
对restore database preview显示结果的思考
查看>>
Windows Server 2008 R2入门之NTFS权限
查看>>
精品软件 推荐 酷我音乐 一个可以下载320k 音质的音乐播放软件
查看>>
heartbeat+DRBD+mysql高可用集群实战
查看>>
The listener supports no services The command completed successfully
查看>>
centos6.5系统编译安装mariadb以及实现主从复制
查看>>
C#获取系统版本信息
查看>>
linux磁盘阵列实战
查看>>
Android应用程序进程启动过程的源代码分析(3)
查看>>
【畅谈百度轻应用】云时代·轻应用·大舞台
查看>>
Forefront_TMG_2010-TMG发布Web服务器
查看>>
MySQL字符集的一个坑
查看>>
区块链将成支付宝国际化的有力武器!
查看>>
理论上分析IP报文的结构各字段的意义
查看>>
OCS 2007 R2搭建准备虚机及快照
查看>>
Oracle 高可用概述
查看>>
存储虚拟化技术之解读
查看>>