POJ1573 Robot Motion(dfs)

别再死记硬背了!用这5个Qt Design Studio小项目,彻底玩转核心组件 本文通过5个Qt Design Studio实战项目,帮助开发者深入理解核心组件的协作与应用。从动态登录界面到游戏化任务列表,每个项目都展示了组件属性与交互设计的巧妙结合,让你不再死记硬背,而是真正掌握Qt Design Studio的核心技能。 阅读详情

Robot Motion

题目链接:

http://poj.org/problem?id=1573

解题思路:

简单模拟即可。

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int dx[] = {0,-1,0,1},dy[] = {-1,0,1,0};
char maze[11][11];
int vis[11][11];
int m,n,ans;

void dfs(int x,int y){
    //cout<<x<<y<<endl;
    if(x<0 || x>=m || y<0 || y>=n){
        printf("%d step(s) to exit\n",ans);
        return ;
    }
    if(vis[x][y]){
        printf("%d step(s) before a loop of %d step(s)\n",vis[x][y]-1,ans-vis[x][y]+1);
        return ;
    }
    ans++;
    if(maze[x][y] == 'W'){
        vis[x][y] = ans;
        dfs(x+dx[0],y+dy[0]);
    }
    else if(maze[x][y] == 'N'){
        vis[x][y] = ans;
        dfs(x+dx[1],y+dy[1]);
    }
    else if(maze[x][y] == 'E'){
        vis[x][y] = ans;
        dfs(x+dx[2],y+dy[2]);
    }
    else{
        vis[x][y] = ans;
        dfs(x+dx[3],y+dy[3]);
    }
}

int main(){
    int x;
    while(scanf("%d%d%d",&m,&n,&x),m+n+x){
        for(int i = 0; i < m; i++)
            scanf("%s",maze[i]);
        ans = 0;
        memset(vis,0,sizeof(vis));
        dfs(0,x-1);
    }
    return 0;
}



C# Winform使用Monaco打造代码编辑器 本文介绍了如何在Winform项目中集成Monaco代码编辑器。通过NuGet安装WebView2控件,创建monaco-editor.html文件加载编辑器,并实现与C#代码的交互。关键步骤包括:初始化WebView2环境、配置Monaco编辑器参数、设置代码变更监听事件以及处理C#与JavaScript之间的通信。注意事项提示了依赖库安装问题的解决方法。该方案实现了功能完整的代码编辑器,支持代码自动保存和实时显示功能。 阅读详情

相关推荐

解密Android相机框架:从HAL到应用层的全链路解析

本文深入解析Android相机框架的全链路架构,从应用层到硬件抽象层(HAL)再到驱动层,详细介绍了CamX-CHI架构的设计哲学与实战应用。通过HAL3接口、V4L2交互机制及Camera2 API的最佳实践,帮助开发者优化相机性能,解决多摄切换、预览卡顿等常见问题,提升成像效率与稳定性。

weixin_29238147的博客 411

POJ 1573 Robot Motion(DFS)

POJ 1573 Robot Motion(DFS) http://poj.org/problem?id=1573 题意:给你一个R*C的棋盘字母矩阵,该矩阵只由N,S,E,W 4个字母构成,分别表示机器人如果走到当前点将往哪个方向走下一步.然后给了你机器人的入口位置(始终在最上一行的某一列做入口),要你输出机器人在该字符矩阵中的行走状况:几步能走出棋盘或者要进入一个几步的死循环. 分析:网

code 1061

[华为]华为无线控制器AC6508简单配置实例

用户需求:3个地址段,分别是领导、员工、访客,访问控制策略是只允许访客上网,不允许访客访问内网。 vlan173为设备的管理地址和AP获取的地址,领导、员工、访客的vlan分别是vlan131/vlan132/vlan133 首先是许可的下载,使用华为的账号登陆http://app.huawei.com/isdp ,然后按照说明输入许可,下载许可,将许可导入到设备。 web界面访问后,直接按照配置向导配置就可以了。 1.基本配置里主要配置license、设备名称、设备时间 2.端口配置:连接上

日子_很简单 2万+

POJ 1573 Robot Motion(模拟、DFS、BFS)

题目链接:http://poj.org/problem?id=1573 分析: 这道题既可以模拟出结果,也可以用DFS或者BFS搜索。 模拟: // 模拟 // #include <bits/stdc++.h> #include <cstdio> #include <cstring> using namespace std; char G[10+7]...

成龙大侠的博客 317

华为云Stack扩容实战:从CMDB配置到计算节点增减容,一份避坑指南

本文详细解析华为云Stack扩容实战,从CMDB配置到计算节点增减容的全流程操作指南。通过典型场景案例和避坑建议,帮助企业高效管理计算资源扩容与减容,确保业务连续性。特别针对华为云Stack的弹性扩容能力提供专业指导,涵盖存储、网络及自动化工具链的配合使用。

weixin_30591551的博客 481

Cadence仿真实战:从零构建高精度带隙基准电压源

本文是一份详细的Cadence仿真实战指南,指导读者从零开始构建高精度带隙基准电压源。文章首先解释了带隙基准电压源稳定输出电压的原理,然后逐步演示了在Cadence Virtuoso环境中如何搭建测试电路、测量关键温度系数、计算并搭建核心电路,并通过参数扫描和迭代调优来驯服温度漂移,最终实现低漂移的基准电压输出。

weixin_29207533的博客 252

POJ 1573 Robot Motion【是搜索,就不要纠结是DFS还是BFS】

Robot Motion Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12845   Accepted: 6234 Description A robot has been programmed to follow the instructions

AC_Dreameng 2320

ESP32连接OneNet云平台实现多设备联动控制完整示例

通过esp32连接onenet云平台,实现远程设备间的智能联动控制,利用MQTT协议完成数据通信,esp32连接onenet云平台后可高效稳定地上传与下发指令,提升物联网系统响应速度与自动化水平。

weixin_42360733的博客 553

POJ 1573 Robot Motion (DFS)

Robot Motion Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12736 Accepted: 6171 DescriptionA robot has been programmed to follow the instructions in its path. Instructions f

滴水穿石,慢慢积累,总会有成果 374

【完美解决】Anaconda3安装后缺失大量文件,没有scripts、Library等目录

Anaconda3是官网下载的:https://www.anaconda.com/distribution/#download-section 我选择的是64位python 3.7的版本。 问题出现及现象: 我自己选择了一个D盘的目录D:\Tools\Anaconda3进行安装,装完后发现conda list命令无法执行,首先都到的是配置环境变量,然后发现安装目录下缺失大量文件(如下图)...

android之行 3万+

Langchain cannot connect with Azure SQL Database

Langchain 无法连接到 Azure SQL 数据库

suiusoar 636

【POJ - 1573】Robot Motion(dfs)

-->Robot Motion 直接中文 Descriptions: 样例1 样例2 有一个N*M的区域,机器人从第一行的第几列进入,该区域全部由'N' , 'S' , 'W' , 'E' ,走到某个区域的时候只能按照该区域指定的方向进行下一步,问你机器人能否走出该片区域,若不能,输入开始绕圈的步数和圈的大小。操作指令如下:N 向上S 向下E 向右W 向左例如,假...

weixin_30435261的博客 183

Hyperledger Fabric 网络搭建详解

写在前面:博主也是因为一些原因刚刚入坑区块链,我认为在我们入门新技术的时候,入门总是最困难的部分,只要入门了,后面学习起来就会越来越轻松,在网上找了很多文章,我觉得大多条理不是很清楚。本文章会详细介绍fabric(v1.0)环境部署,以及在搭建过程我遇到一些问题及解决方案,希望可以帮助到你们。 博主环境机器:VMware15 Ubuntu16.04 fabric(v1.0)环境部署一、必备软件安装1.ubuntu环境安装2.Go语言3.Docker安装4. Docker-Compose 安装二、Fa.

林中有神君 1万+

POJ 1573 Robot Motion (模拟+不回溯的dfs 水题)

Robot Motion Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9159   Accepted: 4441 Description A robot has been programmed to follow the instructions in

Hadis_yuki 1114

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

poj1573 Robot Motion(DFS)

题目链接 http://poj.org/problem?id=1573 题意 一个机器人在给定的迷宫中行走,在迷宫中的特定位置只能按照特定的方向行走,有两种情况:①机器人按照方向序列走出迷宫,这时输出机器人走出迷宫的步数;②机器人在迷宫中陷入了循环,这种情况要输出机器人陷入循环前所走的步数以及循环的步数。 思路 走迷宫问题一般使用BFS或DFS求解,这里我使用DFS来求解。机器人能顺利走...

weixin_30906671的博客 130

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

poj 1573 Robot Motion (链式前向性||dfs)

https://vjudge.net/contest/215355#problem/A A robot has been programmed to follow the instructions in its path. Instructions for the next direction the robot is to move are laid down in a ...

weixin_30530523的博客 98

深度学习工具包 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 1573 Robot Motion G++

#include <iostream> #include <map> #include <cstring> using namespace std; char da[20][20]; int dis[20][20]; map<int,int> dx; map<int,int> dy; int n,m; int lo;//循环...

woniupengpeng的专栏 164

POJ - 1573 Robot Motion

A robot has been programmed to follow the instructions in its path. Instructions for the next direction the robot is to move are laid down in a grid. The possible instruct...

GxhZxx的博客 251

POJ1573 ZOJ1708 UVA10116 UVALive5334 HDU1035 Robot Motion【模拟】

Robot Motion Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 16166 Accepted: 7643 Description A robot has been programmed to follow the instructions in its path. Instructions for the nex...

海岛Blog 713

POJ 1573 Robot Motion

POJ 1573 Robot Motion

NNDXNM的专栏 813

Robot Motion POJ - 1573

A robot has been programmed to follow the instructions in its path. Instructions for the next direction the robot is to move are laid down in a grid. The possible instructions are N north (up the page...

lesfhappy的博客 190

POJ-1573 Robot Motion 模拟水题

  题目链接:http://poj.org/problem?id=1573   随便模拟,水水~ 1 //STATUS:G++_AC_0MS_696KB 2 #include<stdio.h> 3 #include<stdlib.h> 4 #include<string.h> 5 #include<math.h> 6 #...

weixin_30241919的博客 111

Robot Motion(POJ 1573 模拟题)

~题目链接~ http://poj.org/problem?id=1573 输入 3 6 5 NEESWE WWWESS SNWWWW 4 5 1 SESWE EESNW NWEEN EWSEN 0 0 0 结果 10 step(s) to exit 3 step(s) before a loop of 8 step(s) 输入行数、列数、机器人的位置 ...

ddn220120的博客 149

POJ1573 Robot Motion (模拟 | 递归)

附poj1573题目链接http://poj.org/problem?id=1573 题目大意:有一个robot要走迷宫,迷宫的每个点是由NWES四个组成的,每一个字符代表一个方向,其中N向上S向下E向右W向左。现在已知robot在第一行的某列的入口处c,问robot走出迷宫要多少步,或者如果走不出迷宫,则在第几步开始进入陷阱并在陷阱内走了多少步。 思路:只要robot能够越界则就可以

知与谁i的博客 322

POJ 1573 - Robot Motion

很简单的图遍历,模拟即可,但我还是想了好长时间,好在1遍AC了 #include #include using namespace std; char mat[15][15]; int vis[15][15]; int n,m,k,ct,q; void dfs(int i,int j) { if(in||j>m)return; if(vis[i][j])

DC的ACM奋斗史 714
上一篇: Codeforces 488 C. Fight the Monster(模拟)
下一篇: POJ题目分类(2)
yphacker
博客等级 码龄12年 199粉丝 540原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值