HDU 1010 Tempter of the Bone

EPICS Phoebus手册1 EPICS客户端phoebus 手册 阅读详情

http://acm.hdu.edu.cn/showproblem.php?pid=1010

题目读完一开始以为是BFS的题目,求一个最短路然后计算时间...

后来发现不对= =一定要正好到达出口的时候时间也吻合才能出去

所以是DFS...

一道比较基础的DFS,但是需要剪枝= =(一开始TLE了两次,才觉得需要剪枝,蠢哭)

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <cmath>
using namespace std;
char map[10][10];
int ex,ey,sx,sy;
int n,m,t,wall;
bool flag;
int dir[4][2]={{1,0},{-1,0},{0,-1},{0,1}};
void dfs(int x,int y,int cnt)
{
    if(cnt==t)
    {
        if(ex==x&&ey==y)
            flag=true;
        return;
    }
    if(flag)
        return;
    int temp=abs(x-ex)+abs(y-ey)-abs(cnt-t);//奇偶性剪枝,计算当前的离出口的距离
    if(temp>0||temp&1)//位运算判断奇偶性
        return;
    for(int i=0;i<4;i++)
    {
        int fx=x+dir[i][0];
        int fy=y+dir[i][1];
        if(fx>=0&&fx<n&&fy>=0&&fy<m&&map[fx][fy]!='X')
        {
            map[fx][fy]='X';
            dfs(fx,fy,cnt+1);
            map[fx][fy]='.';//回溯
        }
    }
}
int main()
{
    //freopen("in.txt","r",stdin);
    while(scanf("%d%d%d",&n,&m,&t)!=EOF)
    {
        flag=false;
        wall=0;
        if(m==0&&n==0&&t==0)
            break;
        getchar();
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                scanf("%c",&map[i][j]);
                if(map[i][j]=='S')
                {
                    sx=i;
                    sy=j;
                    map[i][j]='X';
                }
                else if(map[i][j]=='D')
                {
                    ex=i;
                    ey=j;
                }
                else if(map[i][j]=='X')
                    wall++;
            }
            getchar();
        }
        if(m*n-wall<=t)
            flag=false;
        else
            dfs(sx,sy,0);
        if(flag)
            printf("YES\n");
        else
            printf("NO\n");


    }
    return 0;
}


国科大学习资料--VLSI测试与可测试设计--2020期末考试试题 国科大学习资料–VLSI测试与可测试设计–2020期末考试试题 国科大学习资料–VLSI测试与可测试设计–2020期末考试试题 国科大学习资料–VLSI测试与可测试设计–2020期末考试试题 一、概念题 1简述可测试性测度与两个主要的测度指标的含义; 2以March C-算法为例,说明March算法的构成,以及March C-算法的故障覆盖率; 3“效果-原因”诊断法和“原因效果诊断法”的不同; 4列举四条扫描设计时出现的问 题及解决办法; 5最少写出1149.1与1500的五点不同; = = = = = 阅读详情

相关推荐

Rstudio安装org.Hs.eg.db

自己也是个小白,初次安装org.Hs.eg.db碰到好多问题,步骤总结如下: 第一,instal.packages()安装,不行则换 BiocManager::install() 第二,如BiocManager不成,说明不是最新版本,可按提示安装最新版 BiocManager::install(version = '3.13') #由于R版本较新,按照提示中的相关信息,安装最新版本的 第三,再次安装 BiocManager::install("org.Hs.eg.db") 第四,之后每个人.

ZH_DDong的博客 2万+

HDU-1010Tempter of the Bone(dfs+奇偶剪枝)

Tempter of the Bone 题目链接 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 157407 Accepted Submission(s): 41882 Problem Description The doggie...

孤风的博客 587

告别CANoe?手把手教你用Python+PCAN搭建汽车诊断脚本(附完整代码)

本文详细介绍了如何利用Python和PCAN硬件搭建高性价比的汽车诊断自动化方案,替代昂贵的CANoe工具。通过开源库python-can和udsoncan实现UDS诊断协议,涵盖硬件选择、环境配置、核心功能实现及性能优化,附完整代码示例,助力开发者快速构建诊断脚本。

weixin_42551227的博客 373

HDU-1010-Tempter of the Bone

HDU-1010-Tempter of the Bone http://acm.hdu.edu.cn/showproblem.php?pid=1010 给这题折腾了半天啊,刚开始用BFS写的,总是WA,后来发现这题要求在给定的时间点到达,不能早,也不能迟,而BFS每次求出的是最短时间,不合题意,于是转用DFS,剪枝的方法是参考HDU的PPT写的,居然还要考虑奇偶性 可以把map看成这样:

菜鸟的程序人生 960

GEE:变异系数法在遥感影像分析中的应用及权重计算

本文介绍了在Google Earth Engine(GEE)平台上基于变异系数法的多指标加权遥感影像分析方法。该方法通过计算每个指标的平均值和标准差,进而计算变异系数来评估指标的变化程度。利用变异系数,我们可以计算每个指标的权重,并将其应用于加权和指数的计算,从而提高遥感影像分析的准确性和可靠性。方法应用于计算Risk-Screening Environmental Indicators (RSEI),并以此为例。

养乐多的博客 2270

高斯过程的数学理解

G澳大利亚的过程是有益的,特别是当我们有少量数据时。当我在制造业担任数据科学家时,我们的团队使用这种算法来揭示我们接下来应该进行哪些实验条件。但是,此算法不如其他算法流行。在这篇博客中,我将通过可视化和 Python 实现来解释高斯过程 [1] 的数学背景。

gongdiwudu的专栏 3605

hdu 1010 Tempter of the Bone(dfs+剪枝)

题目链接:hdu 1010 Tempter of the Bone(dfs+剪枝) 题意:狗狗从S出发,要在正好t秒的时候到达D,每一块地只能走一次,X代表墙不能走,问能否到达 思路:深搜,但是需要剪枝,每走一步,判断能否在剩下的时间中不考虑墙通过最短的路到达出口,若不能直接返回。 #include&lt;cstdio&gt; #include&lt;cstring&gt; #incl...

yz467796454的博客 294

【2025国赛C题】高教社杯全国大学生数学建模竞赛C题思路+代码+论文

【2025国赛C题】高教社杯全国大学生数学建模竞赛C题思路+代码+论文

订阅付费专栏Matlab(奶茶价版),可赠送奶茶价版付费专栏指定代码1份; 2901

HDU1010 Tempter of the Bone(DFS+奇偶剪枝)

题目:HDU1010 Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 161732Accepted Submission(s): 42908 Problem Descriptio...

CarreLiu 224

【SA8155P】AIS Camera相关内容的简单介绍

【SA8155P】AIS Camera相关内容的简单介绍

静谧、淡雅 1695

温度PID控制PLC程序

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

HDU 1010 Tempter of the Bone (DFS+奇偶剪枝)

奇偶剪枝得到新技能

n-1 742

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

HDU1008——Elevator,HDU1009——FatMouse‘ Trade,HDU1010——Tempter of the Bone

使用曼哈顿距离作为预估剩余步数的方法,如果剩余步数不足以到达终点,或者剩余步数与曼哈顿距离的差值的奇偶性不同(意味着无法刚好在剩余时间内到达),则直接返回,避免不必要的递归。如果相邻格子在迷宫范围内,并且是可以通行的或为终点,则进行递归调用,并将剩余时间减少1。:首先,我们需要计算出每个房间的单位成本效益,即每磅猫粮能换取多少磅JavaBeans。接着,找出起点和终点的位置,并调用。:从单位成本效益最高的房间开始,尝试用完所有M磅的猫粮。:在交易的过程中,累计可以获得的JavaBeans总量。

u014114223的博客 1468

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

VC中sqlite的使用

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

hdu_1010 Tempter of the Bone

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010 分析:题意即为再规定的时间内从开始点走在结束点。

徵羽調_xiao賤的专栏 882

HDU-1010 Tempter of the Bone

搜索 HDU-1010 Tempter of the Bone 题目链接:杭电1010 题目大意:小狗要逃生 只能四个方向走 且走过的地方不能再走 还只能在特定的时间逃生 不能多不能少 解题思路:正常的DFS 想的点要多一点 超时了三次 超时要return 到地方没到时间要return 最最重要的是走过的地方要标记为墙 防止出现出口堵住还瞎探索浪费时间的情况 注意这点的分支行不通时要将点还原 代...

鱼头的水题之路 217

HDU.1010 Tempter of the Bone

文章目录一、题目解读1、原题2、分类3、题意4、输入输出格式5、数据范围二、题解参考1、总体思路2、思路①(1).分析(2).AC代码三、评价与后话1、评价2、奇偶剪枝0-1示图绘制代码(C++——EasyX)3、后话 一、题目解读 1、原题 HDU.1010 Tempter of the Bone 2、分类 回溯法 3、题意 给定一个N×MN \times MN×M的迷宫让一只狗去走,迷宫中有一...

God-Excious的博客 808

hdu1010 Tempter of the Bone

hdu 1010 这是一道剪枝的好题;开始时是朴素的当时间t > T || (t >= T&&g[][] != 'D')时,就return;但是还是TLE;之后看了题解说还要加一个奇偶剪枝,就是对每个坐标;将该点坐标的横坐标和纵坐标加起来奇偶性,这样就是斜对角的划分了;很容易知道之后如果S和D的奇偶性不同,还和t的奇偶性对不上就直接output了;但是有个疑问就是问什么一个看似 作用不大的"

hxer 431

hdu 1010 Tempter of the Bone(bfs)

hdu 1010 Tempter of the Bone http://acm.hdu.edu.cn/showproblem.php?pid=1010 ProblemDescription Thedoggiefoundaboneinanancientmaze,whichfascinatedhimalot.However,whenhep...

diansitao5461的博客 199

hdu 1010 Tempter of the Bone[dfs]

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010

835

hdu1010 Tempter of the Bone

Tempter of the Bone                                 ime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)                                             Total Submission(s)

just_for_your_smile的专栏 2万+

HDU【1010】Tempter of the Bone

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010 分析 这道题是求是否能够恰好t步到达目的地,而不是到达目的地的最短路径,所以要用深搜,但需要进行剪枝,这里用到的剪枝的方法是奇偶剪枝。 奇偶剪枝讲解链接:https://blog.youkuaiyun.com/code_pang/article/details/8839432 #include<ios...

yj8023xx的博客 166

hdu1010Tempter of the Bone

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1010 题目大意:给出一个地图的入口和出口,判断在某一刻能不能恰好到达出口。 思路:首先输入迷宫的行和列,时间t和地图(字符和连在一起的地图要存成二维字符数组)。首先用循环找到入口和出口坐标。用dfs来写就可以了。 注意事项:很重要而且不好想的是要剪枝,剪枝要判断的是路程之和不能大于t,而且t-路程之和...

qq_44749483的博客 204

【HDU】1010Tempter of the Bone【dfs+剪枝】

单纯用dfs会超时 要用剪枝优化 提供一组变态数据 6 6 37 S..... ...... ...... ...... ...... D..... NO #include&lt;bits/stdc++.h&gt; #include&lt;cstring&gt; using namespace std; struct node{ int x,y; }; int N,M,T; c...

以梦为马,诗酒趁年华的博客 138

HDU1010——Tempter of the Bone

http://acm.hdu.edu.cn/showproblem.php?pid=1010 这道题讲的是起点是S要到达D点是否可以恰好在规定的T时间到达,而且走的路径不能返回。 解题思路:用的是深搜,搜索是否在T时间是正好到达D点 剪枝:奇偶剪枝,访问范围不能超过图的范围,访问过了或者遇到X都是不能继续访问了。 难点:状态改变有坐标和时间,以时间为判断结束标识。 #inc...

aozhe0658的博客 139

HDU1010 Tempter of the Bone

HDU1010 Tempter of the Bone题目描述 The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground

退役的铜牌狗 307
上一篇: HDU 1312 Red and Black
下一篇: POJ 2488 A Knight's Journey
Visioner7
博客等级 码龄14年 0粉丝 17原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值