hdu1240——Asteroids!

BZOJ4318 期望的线性性质 先看一道和这道类似的题目 描述 某一天 WJMZBMR 在打 osu~~~ 但是他太弱逼了,有些地方完全靠运气:( 我们来简化一下这个游戏的规则: 有次点击要做,成功了就是o,失败了就是x,分数是按 comb 计算的,连续a个 comb 就有分,comb 就是极大的连续o。 比如ooxxxxooooxxx,分数就是 Sevenkplus 闲的慌就看他打了一盘,有些地方跟运... 阅读详情

Asteroids!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3497    Accepted Submission(s): 2312


Problem Description
You're in space.
You want to get home.
There are asteroids.
You don't want to hit them.
 

Input
Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets.

A single data set has 5 components:

Start line - A single line, "START N", where 1 <= N <= 10.

Slice list - A series of N slices. Each slice is an N x N matrix representing a horizontal slice through the asteroid field. Each position in the matrix will be one of two values:

'O' - (the letter "oh") Empty space

'X' - (upper-case) Asteroid present

Starting Position - A single line, "A B C", denoting the <A,B,C> coordinates of your craft's starting position. The coordinate values will be integers separated by individual spaces.

Target Position - A single line, "D E F", denoting the <D,E,F> coordinates of your target's position. The coordinate values will be integers separated by individual spaces.

End line - A single line, "END"

The origin of the coordinate system is <0,0,0>. Therefore, each component of each coordinate vector will be an integer between 0 and N-1, inclusive.

The first coordinate in a set indicates the column. Left column = 0.

The second coordinate in a set indicates the row. Top row = 0.

The third coordinate in a set indicates the slice. First slice = 0.

Both the Starting Position and the Target Position will be in empty space.

 

Output
For each data set, there will be exactly one output set, and there will be no blank lines separating output sets.

A single output set consists of a single line. If a route exists, the line will be in the format "X Y", where X is the same as N from the corresponding input data set and Y is the least number of moves necessary to get your ship from the starting position to the target position. If there is no route from the starting position to the target position, the line will be "NO ROUTE" instead.

A move can only be in one of the six basic directions: up, down, left, right, forward, back. Phrased more precisely, a move will either increment or decrement a single component of your current position vector by 1.

 

Sample Input
  
START 1 O 0 0 0 0 0 0 END START 3 XXX XXX XXX OOO OOO OOO XXX XXX XXX 0 0 1 2 2 1 END START 5 OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO XXXXX XXXXX XXXXX XXXXX XXXXX OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO 0 0 0 4 4 4 END
 

Sample Output
  
1 0 3 4 NO ROUTE
 

Source
 

Recommend
zf   |   We have carefully selected several similar problems for you:   1242  1072  1253  1372  1016 
 

Statistic | Submit | Discuss | Note



图是三维的,方向多了2个,搜索还是一样的


#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

char str[11];
int mat[15][15][15];
int vis[15][15][15];
int dir[6][3]={ {0, 0, -1}, {0, 0, -1}, {0, -1, 0}, {0, 1, 0}, {1, 0, 0}, {-1, 0, 0} };
int n;
struct node
{
	int x,y,z;
	int step;
};

bool is_legal(int x, int y, int z)
{
	if( x < 0 || y < 0 || z < 0 || x >= n || y >= n || z >= n || vis[x][y][z] || mat[x][y][z] == 'X')
		return false;
	return true;
}

void bfs(int sx, int sy, int sz, int ex, int ey, int ez)
{
	queue<node>qu;
	bool flag = false;
	int ans;
	while( !qu.empty() )
		qu.pop();
	memset(vis,0,sizeof(vis));
	node temp1, temp2;
	temp1.x = sx;
	temp1.y = sy;
	temp1.z = sz;
	temp1.step = 0;
	qu.push(temp1);
	vis[temp1.x][temp1.y][temp1.z] = 1;
	while( !qu.empty() )
	{
		temp1 = qu.front();
		qu.pop();
		if(temp1.x == ex && temp1.y == ey && temp1.z == ez)
		{
			ans = temp1.step;
			flag = true;
			break;
		}
		for(int i = 0; i < 6; i ++)
		{
			temp2.x = temp1.x + dir[i][0];
			temp2.y = temp1.y + dir[i][1];
			temp2.z = temp1.z + dir[i][2];
			if( !is_legal(temp2.x, temp2.y, temp2.z) )
				continue;
			vis[temp2.x][temp2.y][temp2.z] = 1;
			temp2.step = temp1.step + 1;
			qu.push(temp2);
		}
	}
	if(flag)
		printf("%d %d\n", n, ans);
	else
		printf("NO ROUTE\n");
}

int main()
{
	while(~scanf("%s%d", str, &n))
	{
		int sx, sy, sz, ex, ey, ez;
		for(int i = 0; i < n; i ++)
			for(int j = 0; j< n; j ++)
			{
				scanf("%s", mat[i][j]);
			}
		scanf("%d%d%d", &sx, &sy, &sz);
		scanf("%d%d%d", &ex, &ey, &ez);
		scanf("%s",str);
		bfs(sx, sy, sz, ex, ey, ez);
	}
	return 0;
}


TorrentToMagnet PHP 转换BT种子到 磁力链 立即下载

相关推荐

tk8610-src_tcl_c_www.9734hucom_WWW.TK27.C0M_tk_

tk8610 projectt k8610 project

hdoj1240

Asteroids! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description You're in space. You want to get home. There are asteroids. You don't w

◆◇丶生如夏花。谁来订阅我的悲伤 901

菲涅尔波带片

菲涅尔波带片的简介,以及matlab绘制

Bestchinese的博客 1万+

Pond

2072. 【2016.10.6NOIP普及模拟】Pond  (File IO): input:pond.in output:pond.out 时间限制: 1000 ms  空间限制: 262144 KB  具体限制   Goto ProblemSet 题目描述        G最后在规定时间内完成了任务,Alice只能放行。         出

cdy1206473601的博客 5万+

从驱动编译到数据传输:RK3588与FPGA的PCIe通信实战解析

本文详细解析了RK3588与FPGA通过PCIe通信的实战过程,涵盖驱动编译、数据传输及性能优化等关键步骤。通过XDMA驱动实现高效DMA传输,适用于视频处理、数据采集等高性能场景,帮助开发者快速掌握嵌入式系统中的PCIe通信技术。

weixin_29214691的博客 523

LSTM模型 轨迹经纬度预测

原始时间序列数据如下所示,我们只取前两列纬度和经度作为输入数据 我们设定用前六个位置信息预测下一个位置,则两个样本的输入输出数据如下所示: 创建LSTM网络训练模型: import numpy as np from keras.layers.core import Dense, Activation, Dropout from keras.layers import LS...

Muzi_Water的博客 2万+

HDU 1240 Asteroids!(BFS)

HDU 1240 Asteroids! You're in space.You want to get home.There are asteroids.You don't want to hit them. InputInput to this problem will consist of a (non-empty) series of up to 100 data sets...

weixin_30263073的博客 130

基于cat12和SPM12进行VBM&SBM数据分析笔记1——数据预处理

基于cat12数据分析基础教程笔记 今年是小编步入研究生生活的第一年,研究方向待定,但主要以磁共振成像为主,以后会不断地总结这方面的知识,涉及MRI扫描,数据分析基础方法理论,软件操作教程,文献阅读笔记总结等等,用来记录我的研究生三年学习过程。编写尽量简洁明了,通俗易懂,本就是小白,也能体会小白的痛。不过这也要谢谢一个人手动@小白(网名),是他教我要把自己所学的写下来,讲出来才能真正的做到输入和输出,查漏补缺。而cat12软件操作是我面临的第一个数据分析的训练,写的可能也不会非常到位,还望各位专业人士指出改

Sophia2023的博客 4万+

ACM-三维BFS之Asteroids!——hdu1240

ACM 三维BFS Asteroids! hdu1240

继续激情,继续奋斗。 5082

多思计组实验实验六 微程序控制器实验

实验六 微程序控制器实验

qq_53089329的博客 3784

基于YOLOv8的人群聚集检测系统:含UI界面设计与数据集应用

人群聚集检测是智慧城市、公共安全和疫情防控等领域的重要任务。本文结合YOLOv8最新目标检测技术,设计并实现了一个高效的人群聚集检测系统,支持可视化UI界面操作,方便用户实时检测和分析视频中的人群密度。本文详细介绍了系统设计思路、使用的数据集、YOLOv8模型训练和推理过程,以及UI界面的开发与整合。最后通过实验验证了该系统的实用性和性能表现。更灵活的模型架构强化的特征融合网络(PAN++)自动混合精度训练支持支持多任务学习(目标检测+分类+分割)预训练模型丰富,适应多种应用场景。

YOLO 433

hdu 1240 Asteroids!

http://acm.hdu.edu.cn/showproblem.php?pid=1240 Asteroids! Problem Description You're in space. You want to get home. There are asteroids. You don't want to hit them.   Input Input to

大太阳 856

Response Instance 详解:在 ABAP OData Client Proxy 中读懂每一次响应

ABAP OData Client Proxy中的Response Instance是关键信息载体,封装了业务数据及调用上下文(如分页、delta link等)。响应实例在执行请求后自动生成,根据请求类型返回特定接口(如READ返回/IWBEP/IF_CP_RESPONSE_READ)。响应抽象与OData版本解耦,支持统一处理V2/V4服务。常见响应类型包括单实体读取、列表读取(支持分页和增量同步)、创建/更新/删除响应等。开发时可通过响应对象的安全类型方法获取数据,如get_business_data获

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 136

Asteroids! (hdu1240)

Asteroids! (hdu1240) 搜索 Problem Description You’re in space. You want to get home. There are asteroids. You don’t want to hit them. 题目直链 题解 简单的bfs搜索,多层迷宫类型的题目 #include<iostream> #include<cstd...

时夜2333的农场 262

用Python爬取大连商品交易所期货实时行情:从入门到实战

python复制编辑# utils.py"豆粕": "M0","铁矿石": "I0","聚乙烯": "L0","玉米": "C0","聚丙烯": "PP0","棕榈油": "P0"本项目展示了:✅ 如何从新浪财经 API获取主力合约实时数据✅ 使用Python异步爬虫技术) 提升效率✅ 利用pandas和matplotlib进行结构化分析与可视化✅ 具备良好的扩展性,可对接金融、农业、能源等数据需求场景✅ 可作为期货量化策略数据源✅ 可嵌入自动化报告系统。

2201_76125261的博客 1247

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

HDU1240 Asteroids!-题目意思详解( 三维BFS)

题目大意:先输入START N 表示这个立方体的层数是N,每一层为一个NxN的正方形。。其实就是一个NxNxN的正方体,输入时一层一层的输入。 输入完立方体后,输入起点和终点的坐标。 输出是 先输出 N 再输出最短路径的步数。如果走不到终点,输出NO ROUTE。 坑点:它输入的起点和终点坐标不与我们输入的立方体对应。要把输出的起点终点描述看仔细了 不能想当然 #include ...

恩特尔派 3186

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Hdu 1240 Asteroids!

Asteroids! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2133    Accepted Submission(s): 1442 Problem Description You're in space. Y

Magic__ 1111

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

HDU-1240 Asteroids!( 三维 BFS)

HDU-1240 Asteroids!( 三维 ) HDU-1240 Asteroids! 题意 已知起点(A,B,C)和终点(D,E,F),在三维空间求最短可由起点到达终点的路径,还需判断有无办法到达。 thinking 用广度优先搜索遍历可行走的路径,如果有一个到达则停止遍历,最先到达的为最短的行走路径。 用 s 三维数组存放太空的情况,然后用 flag 标记能否到达目的地,用 ans 作为答案累加器。从起点开始广度优先搜索,最先到达目的地的 ans 为最少移动次数。需要将走过的路标记为无法走的路避免

Mei_Tou_Nao_的博客 428

hdu1240 Asteroids!

http://acm.hdu.edu.cn/showproblem.php?pid=1240 #include #include #include #include using namespace std; int sx,sy,sz,sum,n,ans,ex,ey,ez; int a[6][3]={{0,0,1},{0,0,-1},{0,1,0},{0,-1,0},{1,0,0},{-1,0,0

小超子的专栏 503

Asteroids! HDU 1240

Asteroids! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3163    Accepted Submission(s): 2110 Problem Description You're in space. Y

1071

HDU 1240 Asteroids!

链接:点击打开链接 和 hdu 1253 胜利大逃亡基本一样,三维bfs,只是输入不同,这里给的起点,终点坐标是z y x,而不是x y z;这里注意一下就可以啦,我就是这里没注意,改错浪费很长时间。。 #include #include #include #include using namespace std; char a[11][11][11]; int b[11][11][11],A

hncu1106401的专栏 415

Asteroids!(hdu1240,dfs)

http://acm.hdu.edu.cn/showproblem.php?pid=1240 Asteroids! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2636    Accepted Submission(s): 

JHC23的专栏 850

hdu 1240 Asteroids!

Asteroids!<br />Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)<br /> Total Submission(s): 1233    Accepted Submission(s): 809<br /><br />Problem DescriptionYou're in space.<br /> You want to get home.<br /> There are

独行闹市无人问,青灯剑影响素琴 827

HDU 1240 Asteroids! (搜索)

Problem Description You're in space. You want to get home. There are asteroids. You don't want to hit them. Input Input to this problem will consist of a (non-empty) series of up to 100 data sets. ...

bravo的博客 848
上一篇: hdu2612——Find a way
下一篇: hdu1372——Knight Moves
tokers
博客等级 码龄12年 71粉丝 700原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值