poj 3009 Curling 2.0 (DFS)

【题解】POJ 3009 Curling2.0(DFS) POJ 3009 Curling2.0 https://vjudge.net/problem/POJ-3009 题意 冰壶游戏,在一个游戏板上进行,板上有一个起点和一个终点并且有许多砖块,问冰壶从起点到终点最少要用的步数。 细则: 开始时,冰壶静止于起点。 冰壶静止时,你可以让它向上下左右移动,并且移动方向上的相邻点不能有砖块,如图a。 冰壶移动中无法主动停下,除非如下几种情况: ... 阅读详情

Curling 2.0
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 13765 Accepted: 5760

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

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.

Each dataset is formatted as follows.

the width(=w) and the height(=h) of the board 
First row of the board
 
... 
h-th row of the board

The width and the height of the board satisfy: 2 <= w <= 20, 1 <= h <= 20.

Each line consists of w decimal numbers delimited by a space. The number describes the status of the corresponding square.

0vacant square
1block
2start position
3goal position

The dataset for Fig. D-1 is as follows:

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

Output

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.

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

Source


题目链接:http://poj.org/problem?id=3009


题目大意:一个有n*m个格子的迷宫,一个小球从起点2出发,3为终点,0为空白格可以走,只能横竖走,1为障碍物,若小球碰到障碍物(走到与1相邻的格子),此处障碍物变为0,小球可改变方向。求小球抵达终点需改变方向的最少次数。若不能抵达终点,输出-1。


解题思路:BFS和DFS都可以做,用DFS需要比较每个答案得到最小值。如果改变方向次数大于10次或者大于已得到的答案值,则不需要在往后递归。


代码入下:

#include <cstdio>
#include <cstring>
int a[22][22];
int dx[4]={0,1,0,-1};//枚举4个方向
int dy[4]={-1,0,1,0};
int n,m,ans;
bool p;
void dfs(int x,int y,int cnt)
{
	for(int i=0;i<4;i++)
	{
		int cx=x,cy=y,step=0;//step用来标记小球是否走了一段直线,若不走,下一个1不能变为0
		//满足条件时按一个固定的方向走直线
		while(cx+dx[i]>=0&&cx+dx[i]<n&&cy+dy[i]>=0&&cy+dy[i]<m&&a[cx+dx[i]][cy+dy[i]]==0)
		{
			cx+=dx[i];
			cy+=dy[i];
			step++;
		}
		if(cx+dx[i]<0 || cx+dx[i]>=n || cy+dy[i]<0 || cy+dy[i]>=m)
			continue;
		//小球抵达终点,比较得到最小答案值
		if(a[cx+dx[i]][cy+dy[i]]==3)
		{
			p=true;
			if(ans>cnt+1)
				ans=cnt+1;
			return;
		}
		//小球碰到障碍物
		//如果改变方向次数大于10次或者大于已得到的答案值,则不需要在往后递归。
		if(step&&ans>cnt+1&&cnt<10&&a[cx+dx[i]][cy+dy[i]]==1)
		{
			a[cx+dx[i]][cy+dy[i]]=0;
			dfs(cx,cy,cnt+1);
			a[cx+dx[i]][cy+dy[i]]=1;
		}
	}
}
int main()
{
	int sx,sy;
	while(scanf("%d%d",&m,&n)!=EOF&&(n+m))
	{
		p=false,ans=10000000;
		memset(a,0,sizeof(a));
		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++)
			{
				scanf("%d",&a[i][j]);
				if(a[i][j]==2)
				{
					sx=i;
					sy=j;
					a[i][j]=0;
				}
			}
		dfs(sx,sy,0);
		if(p&&ans<=10)
			printf("%d\n", ans);
		else
			printf("-1\n");
	}
}


【poj 3009】Curling 2.0 中文题意&题解&代码(C++) poj dfs 阅读详情

相关推荐

掌握POJ3009-Curling 2.0:DFS、向量、回溯与剪枝的实战运用

深度优先搜索算法是一种沿着树的分支进行探索直到末端,然后回溯到上一个节点继续探索的过程。它适用于各种图遍历场景,比如解决迷宫问题、拓扑排序以及求解连通性问题等。std::vector定义于头文件中,它封装了一个动态数组,并提供了一系列成员函数来管理这个数组。创建一个std::vector对象可以使用不同的构造函数来完成。// 创建一个空的vector// 创建一个有5个整数元素,初始值都是0的vector// 创建一个有5个整数元素,初始值都是1的vector。

weixin_28931507的博客 860

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

微生物组数据分析实战:从OTU/ASV过滤到相对丰度转换的标准化流程

本文详细介绍了微生物组数据分析中从原始OTU/ASV表格到标准化相对丰度表格的完整预处理流程。通过基于绝对丰度和出现频率的过滤步骤有效剔除测序噪音与污染,再通过相对丰度转换解决样本间测序深度差异问题,为后续的多样性分析和差异比较奠定可靠基础。文章提供了清晰的R语言实战代码与参数设置思路。

tree的博客 1252

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

Mac上SSH连接神器SecureCRT:从安装到高效使用的完整指南

本文详细介绍了Mac上专业SSH连接工具SecureCRT的安装与高效使用技巧。从核心优势、会话管理到快捷键方案,全面解析如何提升远程开发与服务器管理效率。特别适合需要处理多服务器环境和复杂终端控制的Mac用户,SecureCRT的企业级加密和跨平台同步功能使其成为SSH连接的神器。

weixin_30642561的博客 493

Redis架构演进:从主从、哨兵到集群,如何支撑亿级流量的秒杀场景?

本文深入探讨了分布式缓存Redis的三种核心高可用模式:主从复制、哨兵模式与集群模式。以高并发的电商秒杀业务为切入点,我们分析了每种模式的优缺点和适用场景,并最终选择Redis集群模式作为最佳解决方案。文章提供了基于Spring Boot和Spring Data Redis的完整实现代码,详细展示了如何配置和使用Redis集群来应对高并发、高可用的挑战,旨在帮助开发者在实际项目中做出正确的技术选型和架构设计。

lingRJ777的博客 723

张三玩冰壶:C++用DFS深度优先搜索解POJ3009 Curling 2.0问题

POJ_3009_Curling 2.0 就不放英文题目了,去POJ搜题号就可以看到 简单理解一下题目: 张三去玩一种新出的冰壶项目,在一个棋盘一样的冰面上,他站在其中一格S上,从S点出发,有一些棋盘格有障碍物,他可以沿着上左下右四个方向运动,但是只有碰到障碍物才能停下来,而且碰到障碍物会停在运动方向上障碍物前面那个格子上,障碍物会消失,一个方向算一步,如果步数超过10或者不小心出界都算失败,问张三最短走几步能到终点G。 看一下输入: 一次性输入好几组数据,每一组开头是棋盘的横向距离和纵向距离(非常无奈我在

只想AC的博客 980

Python全栈入门到实战【基础篇 22】生成器与迭代器:底层逻辑与实战场景

Python迭代器与生成器:惰性求值的高效实践 摘要:本文深入解析Python中迭代器和生成器的核心机制与应用场景。迭代器通过实现__iter__()和__next__()方法实现惰性求值,适合处理大数据集和无限序列。生成器作为迭代器的简化实现,通过yield关键字自动实现迭代器协议,代码更简洁。文章详细对比了可迭代对象与迭代器的区别,演示了自定义迭代器和生成器函数的实现方式,并介绍了生成器表达式这一高效替代列表推导式的方案。通过斐波那契数列等实例,展示了惰性求值在内存优化方面的优势,以及生成器在流式数据处

那些看似不起波澜的日复一日,会在某天让你看到坚持的意义 3260

【和小安一起刷题】POJ3009 Curling 2.0 ----深度优先搜索(DFS)

01、题目描述 小伙伴们大家好,这里是和 【和小安一起刷题 】 系列栏目,今天我们要做的是一道求最少步的问题——POJ3009 Curling 2.0,一般的最少步。走迷宫型问题都会涉及广度优先搜索(bfs),但是这道题用深搜来做却更容易实现,话不多说,先看题目吧。 题目链接: POJ3009 Curling 2.0. 题目描述:有一个w*h的冰面,在这些冰面上一些地方有冰块,给定起点(S) 与 终点(G) 的位置。 石头从起点开始运动,可以选择相邻处无冰块的方向前进,每次运动只有撞上冰块才会停止,否则会一

一枝之栖 303

【物联网】基于LORA组网的远程环境监测系统设计(ThingsCloud云平台版)_资料编号34

实现一主多从的LORA组网远程通信,主机和两个从机都配备了STM32F103单片机与 LoRa 模块,主机作为中心设备及WIFI网关,负责接收和发送数据到远程物联网平台和手机APP,两个从机则负责采集数据并通过各自的 LoRa组网将数据发送给主机。

嵌入式阿齐Archie 1万+

044、手持视频抖动严重?OpenCV 光流 + IMU 融合的电子防抖工程方案

本文探讨了基于OpenCV光流和IMU融合的手持视频电子防抖方案。作者从实际工程经验出发,分析了纯光流和纯IMU方案的局限性,指出时间戳对齐和坐标系标定是关键挑战。文章详细介绍了融合滤波器的实现方法,推荐互补滤波替代卡尔曼滤波,并提出了动态调整融合系数的策略。在光流算法优化方面,建议采用网格化FAST特征点和前后向误差检测。最后分享了运动补偿裁剪策略和多线程流水线设计,强调在嵌入式设备上使用NEON指令优化性能。该方案通过精确的时间同步和传感器融合,有效解决了手持拍摄中的高频抖动问题。

ai技术增长的博客 250

POJ-3009 Curling 2.0

POJ-3009 Curling 2.0 题目链接:POJ-3009 题目大意:打冰壶 你可以使冰壶向一个前面一格不为空的方向移动 冰壶遇到障碍会在障碍之前的位置停下来 并且将那个障碍击碎为空格 问你能不能到达给定的终点 能到达的话需要几步 解题思路:dfs即可 主要是注意每次dfs之前需要处理到一行的最末端 即走一行空格 另外注意10步之后默认为不能到达记得返回 这题一开始做麻烦了整整做了一下...

鱼头的水题之路 296

直流无刷电机FOC控制算法 理论到实践 —— 理论(二)

在上一章节,我们对于FOC大体有了一个介绍,本博文将详细描述有关Clark变化、Park变化、反Park变化以及SVPWM的理论实现原理,也即相关数学运算实现。

爱出名的狗腿子 1万+

POJ 3009 dfs回溯

POJ3009 Curling 2.0 Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO format:%lld Java class name:Main Description On Planet MM-21, after their Olympic games this year, curlin...

CC_且听风吟丶的博客 499

Horn-Schunck光流算法的Python实现

光流是计算机视觉领域中的一个重要概念,它描述了图像中物体在时间上的运动。Horn-Schunck光流算法是一种经典的光流估计方法,通过对图像的亮度变化进行建模,来估计像素的运动速度。在本文中,我们将使用Python实现Horn-Schunck光流算法,并提供相应的源代码。请注意,该算法假设图像上的亮度变化主要由物体的运动引起,并且假设光流在整个图像上是稠密的。在上面的示例中,我们首先读取了两个输入图像,然后使用我们实现的Horn-Schunck光流算法估计了它们之间的光流。首先,我们需要导入一些必要的库。

持续更新 495

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

POJ 3009 Curling 2.0(深度优先搜索+剪枝)

POJ 3009  Curling 2.0题目大意:在一块光滑的h*w的矩形平面上,有若干个障碍物,用1表示以及空格用0表示。现在有一个小球在平面上的数字2的地方,通过抛掷这个小球,使其达到数字3所在的敌方。小球可以向上下左右四个方向抛掷,抛掷后小球会不断地滚动,直到撞上障碍物,撞上障碍物后小球会停在障碍物旁边一格,并且这个障碍物会消失;如若不断滚动直到出界,则这种方式不可行;如若在滚动的过程中达...

ELYNABC的博客 438

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

Curling 2.0 POJ - 3009(dfs)

Curling 2.0 POJ - 3009 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 whic...

rainbowsea_1的博客 249

visio安装包

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

深度学习工具包 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

poj 3009 Curling 2.0 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21445 Accepted: 8742 Description On Planet MM-21, after their Olympic games this ye

代码屋 224

POJ 3009 Curling 2.0(DFS深度优先搜索)

//DFS深度优先搜索,WA了5次就因为1个while后面的条件差了一个……教训啊!!!#includeusing namespace std;int map[22][22],possible,minstep,w,h,beginx,beginy;void dfs(int x,int y,int r,int di)//di是4个方向的编号 1:向上 2:向右 3:向下 4:向左

Czy 1011

【poj3009】curling 2.0——dfs

题目: Curling 2.0 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16112   Accepted: 6657 Description On Planet MM-21, after their Olympic games this yea

CFhM_R's Blog 723

poj 3009 Curling 2.0——dfs

Curling 2.0 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

five_east_west的博客 305

poj3009 Curling 2.0 DFS水

http://poj.org/problem?id=3009 题意:给定一个m*n的网格,在这些网格上一些地方有障碍物,给定起点与终点的位置,当石头从起点开始走,撞上障碍才会转弯,否则会一直沿着来时的方向继续前进。撞到障碍后停在障碍前的位置,障碍消失。然后石头可以选择四个方向(相邻处无障碍的方向)前进,问至少需要停多少次才能从起点到达终点。不能到达或者多余10步后游戏失败。如果能到达输...

147

【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
上一篇: poj 3083 Children of the Candy Corn (DFS+BFS)
下一篇: poj 1321 棋盘问题 (简单的DFS)
雨狮子
博客等级 码龄12年 24粉丝 185原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值