poj 3009 (dfs)

LPDDR5X内存技术解析:性能提升与优化策略 内存技术在现代计算系统中扮演着核心角色,其性能直接影响整体系统效率。LPDDR5X作为JEDEC最新标准,通过提升数据传输率至8533Mbps、优化能效比15%以上,并扩展突发长度至32字节,显著提升了移动设备的处理能力。这些改进特别适用于5G通信、AI加速(如昇腾芯片)及8K视频处理等高带宽需求场景。技术原理上,LPDDR5X引入了动态电压频率调整(DVFS)和可编程突发长度等创新机制,有效降低了实际应用中的延迟。在工程实践中,合理的PCB布局和信号完整性验证是确保高速稳定运行的关键。随着AI和8K应用的 阅读详情

刚开始看到最短路,第一反应是bfs,但是题中说明可以破坏路障,所以需要保存状态,bfs保存状态很困难,所以改用dfs,
1.第一次没注意破坏的障碍应该回溯,所以wa
2.第二次用dfs的时候保存当前状态的时候用了全局变量,所以一直没调出来。

#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <stack>
#include <stdlib.h>
#include <stdio.h>

#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ll long long
#define ull unsigned long long
#define uint unsigned int
#define l(x) x<<1
#define r(x) x<<1|1
#define ms(a,b) memset(a,b,sizeof(a))

using namespace std;

struct node {
	int x, y;

	node(){}
	node(int a,int b):x(a),y(b){}
	bool operator==(const node&b) {
		return (x == b.x&&y == b.y);
	}
};

int h, w, mmap[33][33],res;
node beg, en;
int dir[4][2] = {0,-1,0,1,1,0,-1,0};

int run(const node &f, node &r, int d) {
	r = f;
	r.x += dir[d][0];
	r.y += dir[d][1];
	if (mmap[r.x][r.y] == 1) return 0;

	while (1) {
		if (r.x >= h || r.x < 0 ||
			r.y >= w || r.y < 0) return 0;
		if (mmap[r.x][r.y] == 3) {
			return 2;
		}
		if (mmap[r.x][r.y] == 1) {
			r.x -= dir[d][0];
			r.y -= dir[d][1];
			return 1;
		}
		r.x += dir[d][0];
		r.y += dir[d][1];
	}
}

void dfs(node no, int times) {
	if (times == 10)
		return;

	node temp;
	for (int i = 0; i < 4; i++) {
		if (run(no, temp, i) == 1) {
			mmap[temp.x + dir[i][0]][temp.y + dir[i][1]] = 0;
			dfs(temp, times + 1);
			mmap[temp.x + dir[i][0]][temp.y + dir[i][1]] = 1;
		}
		else if (run(no, temp, i) == 2) {
			res = min(res, times+1);
		}
	}
}

int main() {
	while (scanf("%d%d", &w, &h), h) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				scanf("%d", &mmap[i][j]);
				if (mmap[i][j] == 2) {
					beg.x = i;
					beg.y = j;
					//uesd[i][j] = 1;
				}
				else if (mmap[i][j] == 3) {
					en.x = i;
					en.y = j;
				}
			}
		}
		res = INF;
		dfs(beg,0);
		if (res == INF)
			printf("-1\n");
		else
			printf("%d\n", res);
	}
	return 0;
}
(一)深入理解Bluez协议栈之蓝牙Mesh的支持(1/5) BlueZ是Linux官方蓝牙协议栈。它是一个基于GNU General Public License (GPL)发布的开源项目,从Linux 2.4.6开始便成为Linux 内核的一部分。如果你是linux平台开发蓝牙的的工程师,肯定会接触过Bluez协议栈,hciconfig,hciattach,hciconfig等工具都是很好用的工具。 阅读详情

相关推荐

AI智能体赋能Cypress:自动化前端测试的新范式

自动化测试是现代软件工程保障质量的核心实践,其原理是通过脚本模拟用户操作,对软件功能进行验证。随着大语言模型(LLM)和智能体(Agent)技术的发展,测试自动化正迈向智能化新阶段。智能体能够理解自然语言描述的测试需求,并自主规划、执行测试步骤,这为应对前端UI频繁变更、测试用例维护成本高等挑战提供了新思路。在工程实践中,将Cypress这一流行的前端测试框架封装为智能体可调用的标准化技能(Skill),是实现这一愿景的关键。通过设计清晰的交互协议和状态管理机制,智能体可以像人类测试工程师一样“感知”页面状

weixin_33726318的博客 686

poj3009

 package work; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class A3009 {  static int[][] S;  static int W, H;  static int[] Dx = { -1, 0, 1, 0

emslie的博客 427

实战演练:基于Veristand Custom Device的硬件在环(HIL)数据流控制模块开发

本文详细介绍了基于Veristand Custom Device的硬件在环(HIL)数据流控制模块开发实战。通过LabVIEW环境配置、动态路由逻辑构建、实时处理核心开发及性能优化等关键步骤,帮助工程师快速掌握定制化HIL测试系统的开发技巧,提升测试效率与准确性。

weixin_29206669的博客 475

POJ3009(dfs搜索)

题目 POJ3009 一个很有趣的迷宫问题,只能朝一个方向直走,当撞到墙上时可以转弯,且那一块墙消失 思路 数据真的很小,20*20的迷宫,还有转弯的次数限制,完全可以穷举所有路径,然后选最小,可以做一个简单但很实用的优化,减少大量找到答案后的无用搜索 if(cishu&gt;ans||cishu&gt;10) return; 算法我用的是DFS搜索(不会BFS,哭辽),本题和一般迷宫题不同,...

微风的博客 3058

4 种方法识别Linux系统 USB 设备

导读 如果在系统中插入一个设备,尤其是在桌面环境下,比如 USB 设备,它会自动挂载到一个指定目录,一般是在 /media/username/device-label 目录下,之后你就可以进入到该目录下访问那些文件了。然而,在服务器上就不是这么回事了,你必须手动挂载这个设备,并且指定一个挂载点。 查询USB设备 Linux 系统使用 /dev 目录下特定的设备文件来标识插入的

郑帅的博客 1986

《科研伦理与学术规范》期末考试答案2023

26单选(2 分)某学术杂志的评稿人同时是某高校相关专业的硕士生导师,在评判一个稿件的时候,他发现该作者研究的题目很有价值, 他便一边压下这个稿子,一边将稿子的纲要传给自己门下的硕士生, 指导他们使用这个题目独立写出一篇论文,并帮助他们发表在其他期 刊上。D.要善待实验动物,是指在饲养管理和使用实验动物过程中,要采取有效措施,使实验动物免遭不必要的伤害、饥渴、不适、惊恐、折磨、疾病和疼痛,保证动物能够实现自然行为,受到良好的管理与照料,为其提供清洁、舒适的生活环境。张某在压力之下不得不屈从。

Glenseeds的博客 4万+

POJ 3009 用DFS搜最短路径 适合用来学习DFS

说到最短路径,大部分最会想到BFS,DFS求最短路径还是比较少的,我觉得比如只有一种路径可走的话,可以用DFS。 但是这题比较特殊,因为它的规则不像普通迷宫那么简单。具体就不说了。 DFS求最短路径? 那只能是把所有可能到目的地的方法所需步数都比较一下,保存最小的那个值。 所以,搜到一个解之后不能退出DFS,要继续把余下的压在栈里的递归层跑完(当然,跑的时候又会产生新的递归层压入栈),直到所

卡尔 3665

姿态传感器/陀螺仪之IIS2DLPC 应用驱动程序设计

* 转换为°C单位 (参考温度为25°C,灵敏度为16 LSB/°C) */

corlin6688的博客 219

poj 3009 DFS

poj3009 我觉得很好的一个DFS的题,因为题目出得比较“正常”,说直白了就是很水的题,哈哈。符合我们平时做题的正常思路。就一个DFS就可以完成,总的方向是固定的,就要看你运用的能力了,我们应该学会应变,要把方法用活了,这才是高手的境界!多多磨练吧。加油~! #include <iostream>#include <fstream>#i...

weixin_30699831的博客 80

Android 13.0 开机启动优化之PMS扫描apk耗时相关功能优化

在android13.0的系统rom定制化开发中,在系统中开发产品时,会根据客户要求内置第三方app,这时如果内置app过多,或者安装的app过多,在系统开机的过程中 在pms扫描安装app的时候,就会比较耗时,这时候就需要优化下pms扫描安装app这块的功能代码,用多线程来实现pms扫描安装app,来加快开机时间,接下来 来实现这个功能

安卓兼职framework和app工程师的博客 1333

新手秒变高手:使用一键脚本快速安装OpenClaw并完成初始化配置

一键脚本是一种自动化工具,可以帮助用户快速完成软件的安装和配置过程,无需手动执行繁琐的命令。OpenClaw提供了官方的一键安装脚本,让新手用户也能轻松部署OpenClaw。

一键难忘的博客 358

POJ 3009 DFS

题面传送门http://poj.org/problem?id=3009 要点:1.石头会停止于障碍物前或者终点处(即便终点后没有障碍物也会算成功) 2.石头扔出边界没有障碍物则会失败 3.扔石头次数超过10次会失败 开始用BFS写的代码,会超内存,因为要存储每一个状态下的地图。 以下附上DFS代码: #include <iostr...

acmgotoac的博客 139

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

怀旧版电脑GBC模拟器

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

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

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

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

只想AC的博客 980

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

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

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

一枝之栖 303

DFS相关专题练习——POJ 1979, POJ3009, C++ 代码实现

POJ 1979:Red and Black http://poj.org/problem?id=1979 一道简单的DFS入门题,主要需要注意的地方就是输入输出的方式:输入是 scanf 按行读入而非按字符读入;输出需要针对多个输入时给出结果,使用while循环来实现。 #include &amp;lt;iostream&amp;gt; #include &amp;lt;cstdio&amp;gt; using name...

Choly_chen的博客 411

poj3009 Curling 2.0 DFS水

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

147

【DFS】POJ-3009 冰壶游戏

这题很好玩的样子。 假期不妨做出一个可玩的游戏,PC/APP待定、 还可以加入一些道具来增加可玩性。

邂逅黛玛姑娘 1406

POJ 3009 基础搜索 DFS 四

修改了两天。搜索的题目好理解,但是要多练练手感啊......   POJ 3009 冰壶游戏  :http://poj.org/problem?id=3009 题意: 给出 列、行   给出矩阵。  通路为0,墙壁为1,起点为2,终点为3  将冰壶起点击出,不碰到墙壁或出界 不会停止。也就是直线运动。   冰壶撞到墙壁后,在墙壁前面停下!!并且墙壁会碎裂!!   问最少击打次数,使得...

Hide_in_Code 514

poj 3009 Curling 2.0 (dfs)

题意:在一个冰面网格板上,有空白处(无障碍),和障碍块,有一个小石头,给定其起点和终点,求从起点到终点的最小步数 规则:小石头不能在障碍区运动,一旦从某一方向开始运动,不会改变方向,也不会停止,除非碰到障碍物或到达终点才会停止,这为一步。若碰到障碍物,小石头将停在障碍物的旁边,被碰到的一个障碍物将消失。

happy_lcj 1020

poj3009-dfs深搜

有图片插入很麻烦,附上链接。 poj3009有点像打砖块的游戏,不过游戏的目标是让球从起点到达终点,而且只能是直线,每次遇到砖块就停下,被打中的砖块消失,停下以后可以继续朝四个方向投掷,投掷次数不超过十次。(不限制次数的话程序运行时间难以估量) 用简单的深搜就可以了,虽然我觉得也不怎么简单。#include<iostream> #include<cstring> #include<cstdio>

Nayee的专栏 635

poj 3009 dfs 对编程能力不足的认识

好吧,这道题让我无比的虐心。

gaokuilin1060083530的专栏 444
上一篇: 2019 Round Asia Yinchuan C
下一篇: poj 3669
FawkesLi
博客等级 码龄8年 21粉丝 170原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值