hdu 2614 beat

这题最难得地方在于把题目看懂,简单的dfs,没什么好说的

#include<iostream>
#include<cstring>
#define maxn 15+1
using namespace std;
int maxx;
int mapp[maxn][maxn];
int visit[maxn];
int n;
void dfs(int x,int time,int num)
{
	for(int i=1;i<=n;i++)
	{
		if(!visit[i]&&mapp[x][i]>=time)
		{
			visit[i]=1;
			dfs(i,mapp[x][i],num+1);
			visit[i]=0;
		}
	}
	maxx=max(maxx,num);
}
int main()
{
	while(cin>>n)
	{
		memset(visit,0,sizeof(visit));
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++) cin>>mapp[i][j];
		}
		visit[1]=1;
		maxx=0;
		dfs(1,0,1);
		cout<<maxx<<endl;
	}
	return 0;
}
时间: 2024-10-30 12:12:33

hdu 2614 beat的相关文章

HDU 2614 Beat(DFS)

题目链接 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 solvea problem that is easy than problem he had solved. Now yifenfe

HDU 2614 Beat 深搜DFS

这道题目还是比较水的,但是题意理解确实费了半天劲,没办法 谁让自己是英渣呢! 题目大意: 猪脚要解决问题, 他有个习惯,每次只解决比之前解决过的问题的难度要大. 他给我们一个矩阵  矩阵的 i 行 j 列表示 解决完第 i 个问题后再解决第 j 个问题 花费时间为 T[i][j] 也就是 题目的难度. 并且他是从第0个问题开始解决的,第0个问题花费的时间为 0 下面是代码 : 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include&l

I - Beat HDU - 2614 DFS

Beat Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2184    Accepted Submission(s): 1256 Problem Description Zty is a man that always full of enthusiasm. He wants to solve every kind of difficu

DFS HDU 2614

很水的.但是wa了很多遍,因为写num[1][1]... 改成0之后就过了...虽然不知道为什么... Beat Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 659    Accepted Submission(s): 415 Problem Description Zty is a man that always full of

(hdu 简单题 128道)hdu 1194 Beat the Spread!(已知两个数的和u两个数的差求这两个数)

题目: Beat the Spread! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5169    Accepted Submission(s): 2692 Problem Description Superbowl Sunday is nearly here. In order to pass the time waiting f

Hdu 1194 Beat the Spread!

Beat the Spread! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7001    Accepted Submission(s): 3700 Problem Description Superbowl Sunday is nearly here. In order to pass the time waiting for t

杭电 HDU 1194 Beat the Spread!

Beat the Spread! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5192    Accepted Submission(s): 2705 Problem Description Superbowl Sunday is nearly here. In order to pass the time waiting for

(HDU)1194 -- Beat the Spread!(球场赌徒)

题目链接:http://vjudge.net/problem/HDU-1194 给你两个非负整数的和以及差的绝对值,求出这个两个数,不存在输出impossible 坑爹的地方,如果两个数的和是一个奇数,整数解不存在. #include <iostream> #include <cstdio> using namespace std; int main() { int t,a,b,he,ca; scanf("%d",&t); while(t--) { sc

HDU——PKU题目分类

HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201