Curling 2.0 推冰球问题(dfs)

POJ 3009 Curling 2.0 解题报告 业余爱好。所以,算法不一定好,CODING也不一定佳,效率不一定高,只是能通过online judge而已。 立即下载
Problem Description

On Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a square mesh is marked. They use only a single stone. The purpose of the game is to lead the stone from the start to the goal with the minimum number of moves.

Fig. 1 shows an example of a game board. Some squares may be occupied with blocks. There are two special squares namely the start and the goal, which are not occupied with blocks. (These two squares are distinct.) Once the stone begins to move, it will proceed until it hits a block. In order to bring the stone to the goal, you may have to stop the stone by hitting it against a block, and throw again.


Fig. 1: Example of board (S: start, G: goal)

The movement of the stone obeys the following rules:

  • At the beginning, the stone stands still at the start square.
  • The movements of the stone are restricted to x and y directions. Diagonal moves are prohibited.
  • When the stone stands still, you can make it moving by throwing it. You may throw it to any direction unless it is blocked immediately(Fig. 2(a)).
  • Once thrown, the stone keeps moving to the same direction until one of the following occurs:
    • The stone hits a block (Fig. 2(b), (c)).
      • The stone stops at the square next to the block it hit.
      • The block disappears.
    • The stone gets out of the board.
      • The game ends in failure.
    • The stone reaches the goal square.
      • The stone stops there and the game ends in success.
  • You cannot throw the stone more than 10 times in a game. If the stone does not reach the goal in 10 moves, the game ends in failure.


Fig. 2: Stone movements

Under the rules, we would like to know whether the stone at the start can reach the goal and, if yes, the minimum number of moves required.

With the initial configuration shown in Fig. 1, 4 moves are required to bring the stone from the start to the goal. The route is shown in Fig. 3(a). Notice when the stone reaches the goal, the board configuration has changed as in Fig. 3(b).


Fig. 3: The solution for Fig. D-1 and the final board configuration

 

Input
<p>The input is a sequence of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 100.</p><p>Each dataset is formatted as follows.</p><blockquote><p><i>the width(=w) and the height(=h) of the board</i> <br><i>First row of the board</i> <br>... <br><i>h-th row of the board</i></p></blockquote><p>The width and the height of the board satisfy: 2 <= <i>w</i> <= 20, 1 <= <i>h</i> <= 20.</p><p>Each line consists of <i>w</i> decimal numbers delimited by a space. The number describes the status of the corresponding square.</p><blockquote><table id="table1"><tr><td>0 </td><td>vacant square</td></tr><tr><td>1 </td><td>block</td></tr><tr><td>2 </td><td>start position</td></tr><tr><td>3 </td><td>goal position</td></tr></table></blockquote><p>The dataset for Fig. D-1 is as follows:</p><blockquote><p>6 6 <br>1 0 0 2 1 0 <br>1 1 0 0 0 0 <br>0 0 0 0 0 3 <br>0 0 0 0 0 0 <br>1 0 0 0 0 1 <br>0 1 1 1 1 1</p></blockquote>
 

Output
<p>For each dataset, print a line having a decimal integer indicating the minimum number of moves along a route from the start to the goal. If there are no such routes, print -1 instead. Each line should not have any character other than this number.</p>
 

Sample Input
2 1 3 2 6 6 1 0 0 2 1 0 1 1 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 1 1 1 6 1 1 1 2 1 1 3 6 1 1 0 2 1 1 3 12 1 2 0 1 1 1 1 1 1 1 1 1 3 13 1 2 0 1 1 1 1 1 1 1 1 1 1 3 0 0
 

Sample Output
1 4 -1 4 10 -1
 
理解:
在推冰球的时候,冰球的前面必须有空,如果没有碰到障碍物,或者边界的话,要顺着一个方向一直走。
如果碰到障碍物了,障碍物会消失。

//推冰球问题  (记得是求最小的步数) 
#if 0                 //Curling 2.0  
#include<iostream>
#include<cstring>
using namespace std;
int m,n,mapk[25][25]={555},sx,sy,ex,ey,mmin=1000;
int f[4][2]={{-1,0},{0,1},{1,0},{0,-1}};              //上右下左  
bool ff;

int judge(int x,int y)
{
	if(x>=0&&x<m&&y>=0&&y<n)
	{
		return 1;
	}
	else
	{
		return 0;
	}
	
}

void dfs(int x,int y,int step) 
{

	
	if(step>10)
	{
		return;
	}
	
	if(x==ex&&y==ey)
	{
		if(step<mmin)
			mmin=step;
		ff=1;
		return;
	}
	else
	{
		for(int i=0; i<4; i++) 
		{
			int nextx,nexty;
			bool flag=0;
			nextx=x;
			nexty=y;
			
			if(mapk[nextx+f[i][0]][nexty+f[i][1]]==0)	//前面必须有空	
			{
				while(judge(nextx,nexty)&&flag==0)      //向前一直走 一直到边界位置 
				{
					nextx+=f[i][0];                     
					nexty+=f[i][1];
					if(nextx==ex&&nexty==ey)             
					{
						if(step+1<mmin)
							mmin=step+1;
						ff=1;
						return;
					}
					else
					if(mapk[nextx][nexty]==1)           //碰到了墙  
					{
						flag=1;
						mapk[nextx][nexty]=0;
						dfs(nextx-f[i][0],nexty-f[i][1],step+1); //后退一步进行搜索 
						mapk[nextx][nexty]=1;                 
					
					}
				}
				
			}
			
		}
	}
	
	
}


int main()
{
	while(cin>>n>>m&&n+m)
	{
		bool flag1=0;
		memset(mapk,555,sizeof(mapk));
		ff=0;mmin=1000;
		for(int i=0; i<m; i++)
		{
			for(int j=0; j<n; j++)
			{
				cin>>mapk[i][j];
				if(mapk[i][j]==2)
				{
					sx=i;
					sy=j;
					mapk[i][j]=0;	
				}
				else
				if(mapk[i][j]==3)
				{
					ex=i;
					ey=j;
					mapk[i][j]=0;	
				}	
			}	
		}
		
		for(int i=0; i<4; i++)
		{
			int nextx,nexty;
			nextx=sx+f[i][0];
			nexty=sy+f[i][1];
			if(mapk[nextx][nexty]==0&&judge(nextx,nexty))
			{
				flag1=1;
				break;
			}
		}
		
		if(flag1)
		{
			dfs(sx,sy,0);
			if(ff==0)
			{
				cout<<-1<<endl;
			}
			else
			{
				if(mmin>10)
				{
					cout<<"-1"<<endl;
				}
				else
					cout<<mmin<<endl;	
			} 
		}
		else
		{
			cout<<-1<<endl;
		}
	
	
	}
	 
}
#endif


















VMware Converter 6.2.0保姆级教程:从物理机到ESXi主机的完整迁移指南(含常见错误排查) 本文提供VMware Converter 6.2.0从物理机迁移至ESXi主机的完整保姆级教程。详细解析了迁移前的环境规划、核心转换过程步骤、版本差异对比,并重点针对代理安装失败、任务卡顿、虚拟机无法启动等常见错误提供了实战排查与解决方案,确保P2V迁移顺利进行。 阅读详情

相关推荐

2025.06.24【R语言】|clusterProfiler安装与常见报错FAQ全解

本文介绍了clusterProfiler工具的安装方法及常见报错解决方案。安装可通过Bioconductor或Conda完成,需注意安装配套注释包。文中列举了10种常见报错,包括依赖包缺失、ID类型不匹配、物种不支持等问题,并给出具体解决方法。最后总结了GO/KEGG富集分析的标准流程,包括ID转换、富集分析和可视化步骤,为生物信息学分析提供实用参考。建议使用R≥4.2版本,并确保正确调用BiocManager进行安装。

5994

Curling 2.0

Curling 2.0 Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Total Submission(s) : 90   Accepted Submission(s) : 27 Problem Description On Planet MM-21,

raptor 1968

日语五十音图速记攻略:从形象联想法到实战训练

语言学习中的记忆编码与条件反射构建是高效掌握基础的关键。其核心原理在于通过将抽象符号与具象图像、故事或已知概念关联,利用大脑对视觉和叙事信息的天然高记忆效率,从而降低认知负荷,加速识别与反应速度。这一方法的技术价值在于将机械重复转化为意义联结,显著提升长期记忆的牢固度与提取速度。在日语学习这一具体应用场景中,五十音图作为表音文字系统,正是实践这一记忆技术的绝佳对象。通过系统化的形象联想、分组对比(如平假名与片假名的对应关系)以及间隔重复的实战训练,学习者可以高效攻克这一入门难关,为后续的词汇、语法学习铺设坚

weixin_29032489的博客 378

Curling2.0 (P3009)

这个题写出来后,,测试结果是对的,可是一直WA。 后来经过仔细检查,发现少了一点点 #include #include #include #include #include #include #include #include using namespace std; int n,m; int map[22][22]; int ans; int a[4][2]={

jiangjiashi的博客 1500

【PyBind11+anaconda+opencv+windows11+cmake+wsl+vscode】从入门到跑通。构建基于opencv c++的python package

如何安装请详见上文 【PyBind11+anaconda+opencv+windows11+cmake+wsl+vscode】从入门到跑通。构建基于opencv c++的python接口_子韵如初的博客-优快云博客w不需要安装啥x11 、 xming直接mobxterm可以搞定点击右上角的X server打开可视化服务器然后 apt install x11-apps -yxclock 搞定从mobxterm可以看到display的端口X11显示可视化的原理是就是通过X协议,类似于http对linux于w

weixin_43953700的博客 3万+

基于TI C2000的CCS安装与工程创建完整示例

手把手演示基于TI C2000系列的CCS安装过程及首个工程创建步骤,涵盖环境配置与常见问题处理,助力快速上手嵌入式开发,ccs安装和工程搭建不再难。

weixin_42476987的博客 970

【ACM】【DFS】POJ 3009 Curling 2.0

Curling 2.0 点我前往题目链接 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 28809 Accepted: 11408 Description On Planet MM-21, after their Olympic games this year, curling i...

lesileqin的博客 305

LibTV本地部署:AI漫剧创作完整解决方案与实战指南

如果你正在关注AI漫剧创作这个赛道,可能会发现一个有趣的现象:市面上的AI视频工具要么功能单一,要么云端服务昂贵且存在内容审核风险。而今天要介绍的LibTV本地部署方案,或许能为你打开一扇新的大门。 这个方案的核心是Seedance2.0与豆包AI的本地化集成,它真正解决的是创作者对内容自主权、成本控制和创作效率的三重需求。与红果、抖音等平台提供的标准化AI工具相比,本地部署意味着你可以完全掌控生成过程,不受平台规则限制,更重要的是——所有数据都在本地,不存在内容泄露风险。 1. 这篇文章真正要解决的问题

weixin_28745309的博客 523

poj3009Curling 2.0(打冰球,DFS)

题意:要求把一个冰壶从起点“2”用最少的步数移动到终点“3”,其中0为移动区域,1为石头区域,冰壶一旦想着某个方向运动就不会停止,也不会改变方向(想想冰壶在冰上滑动),除非冰壶撞到石头1或者到达终点3,(冰球到达边界会滑出去,不会反弹回来)冰壶撞到石头后,冰壶会停在石头前面,此时(静止状态)才允许改变冰壶的运动方向,而该块石头会破裂,石头所在的区域由1变为0. 也就是说,冰壶撞到石头后,并不会取代...

不积跬步无以至千里 332

【AI智能体】Docker 部署 Coze应用服务实战操作详解

Docker 部署 Coze应用服务实战操作详解

congge 4875

Unitree G1仿人机器人协同搬箱:从仿真搭建到多机协同部署完整指南

Unitree G1仿人机器人协同搬箱技术方案摘要 本文提供了一套完整的Unitree G1人形机器人协同搬箱解决方案,涵盖从仿真环境搭建到多机协同部署的全流程。核心内容包括: 双仿真环境配置:同时搭建Gazebo+ROS Noetic基础仿真环境与Isaac Gym+Mujoco高性能RL训练环境,支持Sim2Sim迁移验证 训练框架搭建:详细配置unitree_rl_gym框架,提供PPO算法定制化训练流程和参数优化方案 数据集应用:整合宇树开源真机数据集(UnifoLM-WBT-Dataset)~~~

huanghm88的专栏 472

POJ 3009 Curling 2.0【DFS】

Curling 2.0 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15453   Accepted: 6392 Description On Planet MM-21, after their Olympic games this year, curlin

wyjwyl的专栏 415

DeepSeek R1-32B医疗大模型的完整微调实战分析(全码版)

【代码】DeepSeek R1-32B医疗大模型的完整微调实战指南(全码版)

AllenLV的博客 5103

POJ3009 Curling 2.0 DFS

题目大意:定义了一种新规则的冰球游戏,在一个w×h的场地移动冰球,场地内有障碍物,冰球从起点到终点的移动方式如下: (1)冰球可以向上下左右中的任意方向移动; (2)冰球一旦开始移动,就不会停下来除非:         (a)冰球到达终点;         (b)冰球碰到了障碍物; (3)冰球碰到障碍物时,冰球会停在障碍物面前,同时障碍物消失。 (4)游戏结束,当且仅当:     

AC_Gibson的专栏 542

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

poj3009——Curling 2.0

题目大意:在有一些障碍的球场打冰球,只能向前后左右扔(不能扔对角线),球会一直按所扔方向走直到撞墙,撞墙时球停在墙的前一个格子处,并且墙消失,问最少需要扔多少次能让球从起始S走到目标G,次数不能超过10次,否则失败 输入:(可以有不超过100个的case,一个case即一个数据集,输入以0 0结束) 第i个case的球场宽度w 高度h(2 <=w<=...

tzyshiwolaogongya的博客 332

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Curling 2.0 - POJ 3009

参考的这个 思路: 枚举冰球下一个可能所在的所有位置然后DFS。 改了一天的BUG,结果发现这个的长宽是反过来输入的,裂开。 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; const int N = 50; int g[N][N]; int n, m; int ex, ey; int xx[4] = {1,

123 419

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

POJ 3009 *** Curling 2.0

题意:有一个h*w的棋盘,某些棋盘上的位置有冰块。打冰球的游戏,对于冰球而言只能向上下左右运动,且会一直运动直到遇到有冰块的位置,或者出界。如果遇到有冰块的位置,则将冰块打碎,冰球停留在往冰块方向上的前一个位置上。如果出界则出局。问最短到达目标需要多少步。(最多只能打10次) 想法:dfs+回溯。 代码如下: #pragma warning(disable:4996)

treeshy的博客 317

POJ 3009 Curling 2.0 DFS

题意:冰球游戏,和迷宫类似,但是每一次碰到障碍则在障碍的旁边停下来,并且障碍被击碎。此时可以重新值掷一次冰球。当掷球次数超过10次则输出-1. 题解: #include using namespace std; #define INF 100000000 int map[2

1087

[原]poj-3009-Curling 2.0-dfs

题目太长就不贴了,题意: 上下左右四联通块,2表示起点,3表示终点,1为block,0为空地,每动一次冰壶,冰壶就会向推动的方向一直移动,直到碰到block或出界,如果碰到block就在block前停下来,同时block消失,如果出界则失败,输出-1,同时,如果在10次推动内都没达到终点也失败,输出-1。如果成功,则输出最少推动次数。 思路: ...

diejixiang8988的博客 192

POJ 3009 Curling 2.0 (DFS)

Curling 2.0 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11412 Accepted: 4827 Description On Planet MM-21, after their Olympic games this year, curlin

Tc的专栏 854

POJ-3009-Curling 2.0

冰球的一道DFS搜索题,需要注意的是冰块可以被冰球击破(如果当前有空点的话),然后进行DFS搜索找到最少次数即可。 由于题目给出最多为10次,则其可作为剪枝·~ 代码: #include #include #include using namespace std; const int maxn=25; int n,m,ans,sx,sy; int map[maxn][maxn],move

z309241990的专栏 574

POJ-3009 Curling 2.0---DFS求最短路

题目链接: https://vjudge.net/problem/POJ-3009 题目大意: 问题:打冰球。冰球可以往上下左右4个方向走,只有当冰球撞到墙时才会停下来,而墙会消失。当冰球紧贴墙时,不能将冰球往那个方向打。冰球出界就当输,超过10次还没将冰球打到目标位置也当输。求用最小次数将冰球打到目标位置,或输出-1表示输了。 思路: 分析:一般来说,求最小步数之类的迷宫问题都是用BF...

weixin_33712987的博客 118
上一篇: Dungeon Master 三维搜索(bfs)
下一篇: Network Saboteur(dfs)
Joined
博客等级 码龄10年 19粉丝 134原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值