ZOJ-1756 Robots

本文探讨了AI在音视频处理、直播流媒体、图像处理AR特效等领域的应用,包括视频分割、语义识别、AR增强现实、物体检测、语音识别、终端AI边缘计算等关键技术。同时涉及图像处理技术如OpenGL ES、OpenCV等,以及音视频编解码算法、硬件编解码等基础技术。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Robots

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Your company provides robots that can be used to pick up litter from fields after sporting events and concerts. Before robots are assigned to a job, an aerial photograph of the field is marked with a grid. Each location in the grid that contains garbage is marked. All robots begin in the Northwest corner and end their movement in the Southeast corner. A robot can only move in two directions, either to the East or South. Upon entering a cell that contains garbage, the robot will pick it up before proceeding. Once a robot reaches its destination at the Southeast corner it cannot be repositioned or reused. Since your expenses are directly proportional to the number of robots used for a particular job, you are interested in finding the minimum number of robots that can clean a given field. For example, consider the field map shown in Figure 1 with rows and columns numbered as shown and garbage locations marked with a 'G'. In this scheme, all robots will begin in location 1,1 and end in location 6, 7.


Figure 1 - A Field Map 


Figure 2 below shows two possible solutions, the second of which is preferable since it uses two robots rather than three.

Figure 2 - Two Possible Solutions


Your task is to create a program that will determine the minimum number of robots needed to pick up all the garbage from a field.


Input

An input file consists of one or more field maps followed by a line containing -1 -1 to signal the end of the input data. A field map consists of one or more lines, each containing one garbage location, followed by a line containing 0 0 to signal the end of the map. Each garbage location consists of two integers, the row and column, separated by a single space. The rows and columns are numbered as shown in Figure 1. The garbage locations will be given in row-major order. No single field map will have more than 24 rows and 24 columns. The sample input below shows an input file with two field maps. The first is the field map from Figure 1.


Output

The output will consist of a single line for each field map containing the minimum number of robots needed to clean the corresponding field.


Sample Input

1 2
1 4
2 4
2 6
4 4
4 7
6 6
0 0
1 1
2 2
4 4
0 0
-1 -1


Sample Output

2
1


#include <stdio.h>

struct node {
	int r;
	int c;
	int f;
};


int main()
{
	struct node path[600], temp;
	int r, c, step, i, j, n, total;
	n = 0;
	while(scanf("%d%d" , &r, &c)) {
		if(r == -1 && c == -1) {
			break;
		}
		else if(r == 0 && c == 0) {
			for(i = 0; i < n-1; i++) {
				for(j = 0; j < n-i-1; j++) {
					if(path[j].r > path[j+1].r || 
						(path[j].r == path[j+1].r && path[j].c > path[j+1].c)) {
							temp = path[j];
							path[j] = path[j+1];
							path[j+1] = temp;
						}
					}
				}
				step = 0;
				total = 0;
				while(total < n) {
					i = 0;
					while(i < n && path[i].f) {
						i++;
					}
					temp = path[i];
					path[i].f= 1;
					total += 1;
					step++;
					for(i = i+1; i < n; i++) {
						if(!path[i].f) {
							if(temp.r == path[i].r) {
								path[i].f = 1;
								temp = path[i];
								total += 1;
							}
							else if(temp.r < path[i].r) {
								if(path[i].c >= temp.c) {
									path[i].f = 1;
									temp = path[i];
									total += 1;
								}
							}
						}
					}
				}
				printf("%d\n", step);
				n = 0;
			} else {
				path[n].r = r;
				path[n].f = 0;
				path[n++].c = c;
			}
		}
		return 0;
}


内容概要:本文档详细介绍了基于MATLAB实现的无人机三维路径规划项目,核心算法采用蒙特卡罗树搜索(MCTS)。项目旨在解决无人机在复杂三维环境中自主路径规划的问题,通过MCTS的随机模拟与渐进式搜索机制,实现高效、智能化的路径规划。项目不仅考虑静态环境建模,还集成了障碍物检测与避障机制,确保无人机飞行的安全性和效率。文档涵盖了从环境准备、数据处理、算法设计与实现、模型训练与预测、性能评估到GUI界面设计的完整流程,并提供了详细的代码示例。此外,项目采用模块化设计,支持多无人机协同路径规划、动态环境实时路径重规划等未来改进方向。 适合人群:具备一定编程基础,特别是熟悉MATLAB和无人机技术的研发人员;从事无人机路径规划、智能导航系统开发的工程师;对MCTS算法感兴趣的算法研究人员。 使用场景及目标:①理解MCTS算法在三维路径规划中的应用;②掌握基于MATLAB的无人机路径规划项目开发全流程;③学习如何通过MCTS算法优化无人机在复杂环境中的飞行路径,提高飞行安全性和效率;④为后续多无人机协同规划、动态环境实时调整等高级应用打下基础。 其他说明:项目不仅提供了详细的理论解释和技术实现,还特别关注了实际应用中的挑战和解决方案。例如,通过多阶段优化与迭代增强机制提升路径质量,结合环境建模与障碍物感知保障路径安全,利用GPU加速推理提升计算效率等。此外,项目还强调了代码模块化与调试便利性,便于后续功能扩展和性能优化。项目未来改进方向包括引入深度强化学习辅助路径规划、扩展至多无人机协同路径规划、增强动态环境实时路径重规划能力等,展示了广阔的应用前景和发展潜力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值