hdu2614 Beat BFS or DFS

工业互联网工控安全与工业质检AI大模型建设方案.pptx 立即下载

Beat

Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1286    Accepted Submission(s): 751


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.


BFS


//hdu2614 Beat BFS
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <iostream>

using namespace std;

const int maxn = 15 + 10;

struct node {
	//pos是当前位置,maxx是到目前为止最大的Tij值,cnt计数
	int pos, maxx, cnt;
	//m用来标记是否走过,m[i] > 0走过,m[i] == 0没有
	//每个节点相当于一个状态,都要有自己的标记情况
	map<int, int> m;
	node() {}
	node(int pos, int maxx, int cnt) : pos(pos), maxx(maxx), cnt(cnt) {}
};

int n, mapp[maxn][maxn], ans;

void bfs() {
	queue<node> Q;

	node ns = node(0, 0, 1);
	ns.m[0]++;

	Q.push(ns);

	while (!Q.empty()) {
		node tn = Q.front(); Q.pop();
		ans = max(ans, tn.cnt);
		int p = tn.pos, maxx = tn.maxx;
		for (int i = 0; i < n; i++) {
			//自己不能到自己,不重复走,不走更小的
			if (i != p && tn.m[i] == 0 && mapp[p][i] >= maxx) {
				node in = tn;
				in.pos = i; in.cnt++; in.maxx = mapp[p][i];
				in.m[i]++;
				Q.push(in);
			}
		}
	}
}

int main()
{
	while (~scanf("%d", &n)) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				scanf("%d", &mapp[i][j]);
			}
		}
		ans = -1;
		bfs();
		printf("%d\n", ans);
	}
	return 0;
}



DFS


//hdu2614 Beat DFS
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 15 + 10;
int mapp[maxn][maxn], ans, n;
bool vis[maxn];

//解到第dep个题,此时最大的时间值为maxx,cnt为已经将dep计算在内的题目数量
void dfs(int dep, int maxx, int cnt) {
	ans = max(ans, cnt);
	for (int i = 0; i < n; i++) {
		//去重,不走自己,不走更小的
		if (!vis[i] && dep != i && mapp[dep][i] >= maxx) {
			vis[i] = true;
			dfs(i, mapp[dep][i], cnt + 1);
			vis[i] = false;
		}
	}
}

int main()
{
	while (~scanf("%d", &n)) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				scanf("%d", &mapp[i][j]);
			}
		}
		ans = -1;
		memset(vis, false, sizeof(vis));
		vis[0] = true;
		dfs(0, 0, 1);
		vis[0] = false;
		printf("%d\n", ans);
	}
	return 0;
}


2024 《计算机网络》实验教学指导书.doc 立即下载

相关推荐

不平衡电网下自抗扰顺序模型预测PWM整流器控制仿真模型(Simulink仿真实现)

内容概要:本文围绕面向城市空中交通的多无人机路径规划问题展开研究,提出了一套融合全局规划、动态避障与局部协同调整的综合路径规划方法。研究内容涵盖基于改进RRT算法与图论的全局路径规划、基于动态风险场和动态窗口法(DWA)的模型预测控制实现动态避障,以及基于分布式协同控制的多无人机局部路径协同策略。通过Matlab平台构建仿真环境,在多种典型城市交通场景下对所提方法进行了系统性验证,结果表明该方法在路径安全性、编队稳定性与任务效率方面表现优异。文章还深入探讨了算法的创新点与未来研究方向,为复杂城市环境下多无人机系统的自主协同提供了理论支撑与技术路径。; 适合人群:具备自动化、控制理论、计算机科学或相关领域基础知识,从事无人机系统、智能交通、路径规划、多智能体协同控制等方向研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①为城市空中交通系统中的多无人机安全、高效飞行提供可靠的路径规划解决方案;②支持在复杂、动态的城市场景中开展无人机自主导航、编队飞行与协同控制的技术研究与仿真验证。; 阅读建议:建议结合提供的Matlab代码进行实践操作,重点关注算法的具体实现细节、参数配置对性能的影响以及不同仿真场景下的实验设计,以深入理解各模块的集成逻辑与实际应用效果。

hdu(2614) Beat

简单深搜; 题意;解决问题的难度是递增的,并且每次都是先从解决第一个问题开始的; 所以用回朔搜索取最大值,注意开始的时候就先把第一个问题给标记了;     #include"stdio.h" #include"string.h" int map[100][100]; int visit[100]; int n,max; void bfs(int k,int h,int t)

飞雪---晨 680

AD9253 LVDS 高速ADC驱动开发

对应:data clock时钟为500M DDR mode。具体内容:下文的参考博客写的很清楚,我就不详细写了。参考博客clock align模块不完整,本文新增这个模块。3、该款ADC工作在125Msps下,14bit - 2Lane - 1frame 模式。2、查阅Xilinx xapp524手册。1、查阅AD9253器件手册。

CAOXUN_FPGA的博客 2105

(HDU2614) Beat-DFS

Beat Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2441    Accepted Submission(s): 1395   Problem Description Zty is a man that always ful...

知乎:https://www.zhihu.com/column/c_1956128398884729528 207

同花顺【红绿趋势】幅图指标 源码分析

a10:IF(差值<=0 ,0 ,差值*0.2 ,4 ,0),STICK,linethick5,colorred;a7:IF(差值<=0 ,0 ,差值*0.8 ,4 ,0),STICK,linethick5,colorred;a8:IF(差值<=0 ,0 ,差值*0.6 ,4 ,0),STICK,linethick5,colorred;a6:IF(差值<=0 ,0 ,差值*1 ,4 , 0),STICK,linethick5,colorred;DRAWICON(先锋<0,-25,1);

zhibiaogong的博客 4049

kettle连接达梦资源库数据库插件

kettle自定义插件plugin database plugin 达梦插件 dm插件

weixin_42122126的博客 2169

2016蓝桥杯C/C++省赛B组第6题 方格填数 DFS

方格填数 如下的10个格子    +--+--+--+    |  |  |  | +--+--+--+--+ |  |  |  |  | +--+--+--+--+ |  |  |  | +--+--+--+ (如果显示有问题,也可以参看【图1.jpg】) 填入0~9的数字。要求:连续的两个数字不能相邻。 (左右、上下、对角都算相邻) 一共

EventQueue的博客 9505

从圆形到椭圆:CenterNet中高斯热图半径的自适应优化策略

本文深入探讨了CenterNet目标检测模型中高斯热图生成策略的优化,针对传统圆形高斯核在处理长宽比差异大目标时的局限性,提出了自适应椭圆高斯核的解决方案。通过数学推导和代码实战,详细阐述了如何根据目标边界框尺寸动态计算椭圆长短轴半径,生成更贴合目标几何形状的热图监督信号,从而有效提升模型,尤其是对无人机、车辆等不规则目标的定位精度。

alice7model的博客 985

2016蓝桥杯省赛C/C++B组7题剪邮票 DFS枚举组合情况BFS判联通

剪邮票 如【图1.jpg】, 有12张连在一起的12生肖的邮票。 现在你要从中剪下5张来,要求必须是连着的。 (仅仅连接一个角不算相连) 比如,【图2.jpg】,【图3.jpg】中,粉红色所示部分就是合格的剪取。 请你计算,一共有多少种不同的剪取方法。 请填写表示方案数目的整数。 注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。

EventQueue的博客 6970

【3】 灰度变换(1)

第三章(1)【总三】

课题分离 659

AUTOSAR进阶图解==>AUTOSAR_SWS_CANStateManager

AUTOSAR CAN状态管理器(CanSM)摘要 CanSM是AUTOSAR通信栈中的关键模块,负责管理CAN网络状态和模式转换。主要功能包括: 控制CAN控制器/收发器工作模式(STARTED/STOPPED,NORMAL/STANDBY) 处理三种网络状态(全通信、静默通信、无通信)之间的转换 监控和处理总线关闭(Bus-Off)事件 与ComM、CanIf、BswM等模块协同工作 CanSM通过状态机管理网络状态转换,支持可配置的总线关闭恢复策略。它为每个CAN网络维护独立的状态机,实现网络状态的精

一名留德华的,康德的信徒的,专注于汽车电子领域的博客 5578

hdu5952 Counting Cliques DFS

Counting Cliques Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 184    Accepted Submission(s): 56 Problem Description A clique is

EventQueue的博客 1950

网口通信实战(C#完整版):基于TCP协议的工业仪表数据采集系统开发

工业现场中80%的智能仪表(压力/温度/液位/流量/数显仪表)、采集模块、测控终端均支持TCP网口通信,这类设备的TCP通信有鲜明的工业特性:基于字节流的自定义二进制协议、一问一答的主从通信模式、对数据完整性/稳定性要求极高。本次实战是纯工业级落地项目,基于C# WinForm + .NET Framework 4.8(工业上位机标配)✅纯原生无依赖:零第三方类库/控件,仅用C#原生,源码可100%复用、无引用冲突、工控机完美兼容;✅双采集模式完美适配:同时实现「单次手动采集」+「连续自动采集」

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 1799

蓝桥杯某题 dfs 符合要求的14位整数排列

今有7对数字:两个1,两个2,两个3,...两个7,把它们排成一行。 要求,两个1间有1个其它数字,两个2间有2个其它数字,以此类推,两个7之间有7个其它数字。如下就是一个符合要求的排列:   17126425374635   当然,如果把它倒过来,也是符合要求的。   请你找出另一种符合要求的排列法,并且这个排列法是以74开头的。   注意:只填写这个14位的整数,不能填写任何

EventQueue的博客 1260

WinCC 7.5 读取 SQL server2016 中的表格数据

环境 win10 SQL Server 2016 WinCC V7.5 SP2 1 安装SQL Server 2016 2 选择服务器名称 .\WINCC 3 建数据库

skr? 7139

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

codeforces 659E New Reform

E. New Reform time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Berland has n cities connected by m bidirectio

EventQueue的博客 1028

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

hdu5676 ztr loves lucky numbers DFS+二分

ztr loves lucky numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 330    Accepted Submission(s): 133 Problem Description ztr

EventQueue的博客 974

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

hdu5723 Abandoned country

Abandoned country Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 938    Accepted Submission(s): 251 Problem Description An abandon

EventQueue的博客 923

DFS暴力求某集合上的某种的组合情况

看到有很多用DFS,八皇后,N骑士,还有什么给几个碎片拼正方形的,其实都是在一定数上的组合情况的枚举,好多都是本质上都是一样的,但是经常写的时候还是会卡一下,当个模板吧 比如这个从12个格子里不重不漏地找5个块的组合情况,数量上应该是792 #include #include #include #include usin

EventQueue的博客 916

蓝桥杯历届试题 大臣的旅费 记忆化搜索DFS

历届试题 大臣的旅费   时间限制:1.0s   内存限制:256.0MB        问题描述 很久以前,T王国空前繁荣。为了更好地管理国家,王国修建了大量的快速路,用于连接首都和王国内的各大城市。 为节省经费,T国的大臣们经过思考,制定了一套优秀的修建方案,使得任何一个大城市都能从首都直接或者通过其他大城市间接到达。同时,如果不重复经过大城市,从首都

EventQueue的博客 828

CodeForces 377A

原来是想在填X的时候一边判断 ’.‘ 区域的连通性,发现很麻烦,说不定还超时。 另一种思路是,求出’.‘的数量是cou,需要填k个’X‘,则只需要找到一个有cou-k 个’.‘的连通域就可以了,剩下的k个’.‘全换成’X ‘ #include #include #include int n, m, k; char mapp[510][510]; int vis[510][510];

EventQueue的博客 816

POJ3984

简单搜索,用一个结构体栈来储存临时路径,一个结构体数组来存储最短路径,实时更新最短路径的结构体数组,最后输出 #include #include #include #define N 5 struct step { int tx; int ty; }s[10000], t[10000]; int sizee = sizeof(t); int maze[N][N]; i

EventQueue的博客 755

POJ1562

题意是在途中找@块的数量,算上斜方向的。#include #include #include char a[110][110]; int vis[110][110]; int sizev = sizeof(vis); int cou, m, n; int dir[8][2] = {{1, 0}, {1, -1}, {0,1}, {0,-1}, {-1, 0}, {-1,1}, {1, 1}

EventQueue的博客 720

poj1011-Sticks dfs各种剪枝

Sticks Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 133058   Accepted: 31236 Description George took sticks of the same length and cut them randomly unt

EventQueue的博客 675

hdu4499 Cannon DFS

Cannon Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 1062    Accepted Submission(s): 608 Problem Description In Chinese Chess, th

EventQueue的博客 631
上一篇: hdu4283 You Are the One 区间dp 记忆化搜索or递推
下一篇: poj3414 Pots BFS
Daemoonn
博客等级 码龄11年 42粉丝 198原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值