OpenJ_Bailian - 1077 :Eight (八数码)

POJ4115:鸣人和佐助(广搜) POJ4115:鸣人和佐助 描述 已知一张地图(以二维矩阵的形式表示)以及佐助和鸣人的位置。地图上的每个位置都可以走到,只不过有些位置上有大蛇丸的手下,需要先打败大蛇丸的手下才能到这些位置。鸣人有一定数量的查克拉,每一个单位的查克拉可以打败一个大蛇丸的手下。假设鸣人可以往上下左右四个方向移动,每移动一个距离需要花费1个单位时间,打败大蛇丸的手下不需要时间。如果鸣人查克拉消耗完了,则只可以走 阅读详情

The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15 on it, and all packed into a 4 by 4 frame with one tile missing. Let's call the missing tile 'x'; the object of the puzzle is to arrange the tiles so that they are ordered as: 

 1  2  3  4 
 5  6  7  8 
 9 10 11 12 
13 14 15  x 


where the only legal operation is to exchange 'x' with one of the tiles with which it shares an edge. As an example, the following sequence of moves solves a slightly scrambled puzzle: 

 1  2  3  4    1  2  3  4    1  2  3  4    1  2  3  4 
 5  6  7  8    5  6  7  8    5  6  7  8    5  6  7  8 
 9  x 10 12    9 10  x 12    9 10 11 12    9 10 11 12 
13 14 11 15   13 14 11 15   13 14  x 15   13 14 15  x 
           r->           d->           r-> 


The letters in the previous row indicate which neighbor of the 'x' tile is swapped with the 'x' tile at each step; legal values are 'r','l','u' and 'd', for right, left, up, and down, respectively. 

Not all puzzles can be solved; in 1870, a man named Sam Loyd was famous for distributing an unsolvable version of the puzzle, and 
frustrating many people. In fact, all you have to do to make a regular puzzle into an unsolvable one is to swap two tiles (not counting the missing 'x' tile, of course). 

In this problem, you will write a program for solving the less well-known 8-puzzle, composed of tiles on a three by three 
arrangement. 

Input

You will receive a description of a configuration of the 8 puzzle. The description is just a list of the tiles in their initial positions, with the rows listed from top to bottom, and the tiles listed from left to right within a row, where the tiles are represented by numbers 1 to 8, plus 'x'. For example, this puzzle 

 1  2  3 
 x  4  6 
 7  5  8 


is described by this list: 

 1 2 3 x 4 6 7 5 8 

Output

You will print to standard output either the word ``unsolvable'', if the puzzle has no solution, or a string consisting entirely of the letters 'r', 'l', 'u' and 'd' that describes a series of moves that produce a solution. The string should include no spaces and start at the beginning of the line.

Sample Input

 2  3  4  1  5  x  7  6  8 

Sample Output

ullddrurdllurdruldr
#include <iostream>
#include <bitset>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <set>
using namespace std;
int goalStatus = 123456780; //目标状态

const int MAXS = 400000; char result[MAXS];   //要输出的移动方案
struct Node {
    int status; //状态
    int father; //父节点指针,即myQueue的下标
    char move;   //父节点到本节点的移动方式 u/d/r/l
    Node(int s,int f,char m):status(s), father(f),move(m) { } Node() { }
};
Node myQueue[MAXS];  //状态队列,状态总数362880
int qHead = 0; //队头指针
int qTail = 1;  //队尾指针
char moves[] = "udrl"; //四种移动

int NewStatus( int status, char move) {
    //求从status经过 move 移动后得到的新状态。若移动不可行则返回-1
    char tmp[20];
    int zeroPos; //字符'0'的位置
    sprintf(tmp,"%09d",status); //需要保留前导0
    for( int i = 0;i < 9; ++ i )
        if( tmp[i] == '0' ) {
            zeroPos = i;
            break;
        } //返回空格的位置
    switch( move) {
        case 'u':
            if( zeroPos - 3 < 0 )
                return -1; //空格在第一行
            else {
                tmp[zeroPos] = tmp[zeroPos - 3];
                tmp[zeroPos - 3] = '0';
            }
            break;

        case 'd':
            if( zeroPos + 3 > 8 )
                return -1; //空格在第三行
            else {
                tmp[zeroPos] = tmp[zeroPos + 3];
                tmp[zeroPos + 3] = '0';
            }
            break;
        case 'l':
            if( zeroPos % 3 == 0)
                return -1; //空格在第一列
            else {
                tmp[zeroPos] = tmp[zeroPos -1];
                tmp[zeroPos -1 ] = '0';
            }
            break;

        case 'r':
            if( zeroPos % 3 == 2)
                return -1; //空格在第三列
            else {
                tmp[zeroPos] = tmp[zeroPos + 1];
                tmp[zeroPos + 1 ] = '0';
            }
            break;
    }
    return atoi(tmp);
}

bool Bfs(int status) {
    //寻找从初始状态status到目标的路径,找不到则返回false
    int newStatus;
    set<int> expanded;
    myQueue[qHead] = Node(status,-1,0);
    expanded.insert(status);
    while ( qHead != qTail) { //队列不为空 
        status = myQueue[qHead].status; 
        if( status == goalStatus ) //找到目标状态 
            return true; 
        for( int i = 0;i < 4;i ++ ) { //尝试4种移动 
            newStatus = NewStatus(status,moves[i]); 
            if( newStatus == -1 )   
                continue; //不可移,试下一种 
            if(expanded.find(newStatus)!=expanded.end()) 
                continue; //已扩展过,试下一种 
            expanded.insert(newStatus);

            myQueue[qTail++] = Node(newStatus,qHead,moves[i]); //新节点入队列
        } 
        qHead ++;
    } 
    return false;
}

int main(){ 
    char line1[50];  
    char line2[20]; 
    while( cin.getline(line1,48)) { 
        int i,j; 
        //将输入的原始字符串变为数字字符串 
        for( i = 0, j = 0; line1[i]; i ++ ) { 
            if( line1[i] != ' ' ) { 
                if( line1[i] == 'x' )  
                    line2[j++] = '0'; 
                else  
                    line2[j++] = line1[i]; 
            } 
        } 
        line2[j] = 0; //字符串形式的初始状态

        if( Bfs(atoi(line2))) { 
            int moves = 0; 
            int pos = qHead; 
            do {  //通过father找到成功的状态序列,输出相应步骤 
                result[moves++] = myQueue[pos].move; 
                pos = myQueue[pos].father; 
            } while( pos); //pos = 0 说明已经回退到初始状态了 
            for( int i = moves -1; i >= 0; i -- ) 
                cout << result[i]; 
            } 
            else 
                cout << "unsolvable" << endl;
    }
    return 0;
}

 

五、2K0300 久久派开发板的GPIO控制与Shell脚本自动化实战 本文详细介绍了基于龙芯2K0300处理器的久久派开发板的GPIO控制方法,通过sysfs文件系统实现LED控制和传感器读取。重点讲解了Shell脚本自动化实战,包括LED闪烁、流水灯效果和传感器数据采集,为物联网项目开发提供完整解决方案。 阅读详情

相关推荐

【WiFi软件开发】IOCTL和Netlink----用户空间和内核空间交互的两种方式

linux开发中通常会涉及用户空间和内核模块的交互。本文介绍了两种典型的用户空间和内核模块通信方式:ioctl和netlink

liuwe1ye的博客 2347

OpenJ_Bailian - 4115 鸣人和佐助(BFS特殊判重)

佐助被大蛇丸诱骗走了,鸣人在多少时间内能追上他呢?已知一张地图(以二维矩阵的形式表示)以及佐助和鸣人的位置。地图上的每个位置都可以走到,只不过有些位置上有大蛇丸的手下,需要先打败大蛇丸的手下才能到这些位置。鸣人有一定数量的查克拉,每一个单位的查克拉可以打败一个大蛇丸的手下。假设鸣人可以往上下左右四个方向移动,每移动一个距离需要花费1个单位时间,打败大蛇丸的手下不需要时间。如果鸣人查克拉消耗完了,则只可以走到没有大蛇丸手下的位置,不可以再移动到有大蛇丸手下的位置。佐助在此期间不移动,大蛇丸的手下也不移动。请问

weixin_44376865的博客 534

Yolov2 训练时anchor是如何使用的?build_target

0.简略描述 1.将真值检测框变换到特征图尺度上 2.计算以特征图每个网格中心为中心点时所有锚框与真值检测框的交并比 3.取与真值检测框交并比最大的锚框的id,及真值检测框中心所在cell的id,有此,可将真值检测框与预测结果对应起来 4.计算位置回归损失,置信度损失,分类损失 1,网络的输出 图1 yolov2 网络对于检测框位置大小的输出是: 对于1个batch网络的输出的shape为[batch_size, H*W*num_anchors, 5+num_classes], 其中: num_

机器人视觉感知 2816

poj 1077 Eight

题目: 是一道经典的八数码问题。将一个3×3的矩阵,通过每次和四周的数字进行互换,最终达到目标状态。其中用字母“l”表示相左移动,“u”表示向上,“r”表示向右,“d”表示向下,最后结果,输出移动的字母。 样例: 目标位置是 初始位置是: 为了从初始位置到达目标位置,需要先将x与5换位置,再与6换位置,也就是先...

zjsru_Beginner的博客 574

某手 v8.x 签名计算方法(二) sig和__NS_sig3

一、目标 今天的目标是 sig和__NS_sig3,咱们抓个包先 二、步骤 sig目测像是MD5 先jadx搜索 sig= ,没有找到结果。 再试试 sig ,晕倒 6k多个结果,突然灵光一闪,这些参数,必然是要加入到 Map中,那么我们搜索 "sig" 应该就是这个 CPU.getClock,Hook之 var signCls = Java.use('com.yxcorp.xxx.util.CPU'); signCls.getClock.implementation = function(a,b,c

fenfei331的博客 2428

什么是数据挖掘?数据挖掘到底在解决什么问题?

本文我将借助5W1H的思想来带你从整体上了解一下数据挖掘。比如什么是数据挖掘为什么要做数据挖掘在哪些场景下用数据挖掘怎么做数据挖掘第一个问题,什么是数据挖掘?这个问题看似很简单,但似乎也很难有一个明确的答案。如果非要给数据挖掘一个定义的话,那么我认为数据挖掘就是寻找数据中隐含的知识,并用于产生商业价值。也就是说它是我们在数据中,尤其是在大量的数据中找到一些有价值,甚至是非常有价值的东西的一种手段。

m0_64336780的博客 1万+

算法基础:4115:鸣人和佐助--广度优先搜索

题目: 佐助被大蛇丸诱骗走了,鸣人在多少时间内能追上他呢? 已知一张地图(以二维矩阵的形式表示)以及佐助和鸣人的位置。地图上的每个位置都可以走到,只不过有些位置上有大蛇丸的手下,需要先打败大蛇丸的手下才能到这些位置。鸣人有一定数量的查克拉,每一个单位的查克拉可以打败一个大蛇丸的手下。假设鸣人可以往上下左右四个方向移动,每移动一个距离需要花费1个单位时间,打败大蛇丸的手下不需要时间。如果鸣人查克拉消耗完了,则只可以走到没有大蛇丸手下的位置,不可以再移动到有大蛇丸手下的位置。佐助在此期间不移动,大蛇丸的手下也

qq_46470984的博客 547

路径规划 | 详解混合A*算法Hybrid A*(附ROS C++/Python/Matlab仿真)

Hybrid A*算法通过结合连续状态空间搜索、运动约束考虑和轨迹优化等技术,弥补了普通A*算法在高维连续空间和的不足,提高了路径规划的效率和鲁棒性,广泛应用于车规级路径规划。本文详细图解Hybrid A*算法的原理——启发式、维诺耗散项、节点扩展法则等,并给出ROS C++、python、matlab三种语言的仿真实现加深理解

FRIGIDWINTER的博客 1万+

POJ 1077 Eight(据说此题不做人生不完整~~~)

分析: 八数码问题,典型的搜索题。本题有3个点。一个是搜索方式,一个是判重,一个是状态表示。搜索方法有多种,速度从低到高是bfs,双向bfs,A*,IDA*。POJ的discuss说BFS一般在500MS左右。但是本人只会BFS,就先用了BFS的做法。网上最通俗的做法是用康托展开和逆展开来判重和表示状态,再慢一点的就是用一个数组表示状态。 我是不想用康托展开,又觉得数组太慢。所以想了很

行走世间,皆为妖怪 1145

OmniParser V2 和 OmniTool 让 AI 来控制 Windows 设备

OmniParser V2 和 OmniTool 是由微软开发的一套工具,通过屏幕解析技术让 AI 能够理解和控制 Windows 设备。OmniParser V2 是一款数据解析工具,可以解读屏幕内容,并将内容传递给大模型OmniTool 则是一个运行 Windows Agent 的工具,提供 Windows 界面给 AI 操作。

简简单单Onlinezuozuo 2730

2026年全国青少年信息素养大赛算法应用主题赛(C++赛项初赛模拟卷1及答案解析)

2026年全国青少年信息素养大赛算法应用主题赛(C++赛项初赛模拟卷1及答案解析)

王老师青少年编程 2023

鸣人和佐助

描述 佐助被大蛇丸诱骗走了,鸣人在多少时间内能追上他呢? 已知一张地图(以二维矩阵的形式表示)以及佐助和鸣人的位置。地图上的每个位置都可以走到,只不过有些位置上有大蛇丸的手下,需要先打败大蛇丸的手下才能到这些位置。鸣人有一定数量的查克拉,每一个单位的查克拉可以打败一个大蛇丸的手下。假设鸣人可以往上下左右四个方向移动,每移动一个距离需要花费1个单位时间,打败大蛇丸的手下不需要时间。如果鸣

u010524510的博客 4955

CKA-CN考试之路----1

后的的任意位置,但-n 和autoscale 必须是相连的.后面不再对命名空间部分做解释了.说明配置正确,如果无法保存退出,再次检查对齐.不用怀疑一定是复制的时候少了字母或者对齐出错.运行以下命令确认红色箭头的值和题目要求是否一致。将文档中的内容复制并粘贴到对应位置.,后续不再提醒yaml的对齐。确认脚本check1.sh。

Q先生 606

POJ 1077 Eight(BFS)

Description The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15 on it, a

jinghui_7的博客 484

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

八数码 poj1077 Eight(A*、IDA*)

八数码主要参考:刘亚宁学长的八数码八境界 等 A*主要参考:百度百科,初识A*算法,深入A*算法 等 IDA*主要参考:http://blog.youkuaiyun.com/urecvbnkuhbh_54245df/article/details/5856756,http://blog.youkuaiyun.com/nomad2/article/details/6562140 等 人工智能课的作业,借此研究下八数码

冰 2764

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

百练4115 鸣人和佐助(变式BFS)

百练4115 鸣人和佐助(变式BFS)

Ema1997的博客 2483

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

Eight POJ - 1077(经典双向BFS八数码)

题意 就是问你怎么走可以最后走成:1 2 3 4 5 6 8 x 的状态 思路 由于起点和终点已经知道所以可以用双向bfs,我们考虑bfs的树状图形 我们可以看到阴影部分的地方就是无用的地方,我们双向搜索的话,肯定能找到相同的一层!(注意这里是一层),所以我们双向bfs的策略就是:你走一层,我走一层,这样相会的时候就是路径最短的时候,因为层数相当于步数!至于路劲的问题就很简单了,用pr...

leekerian的博客 381

1077 Eight:八数码问题变形:从bfs到双向bfs+hash到A*启发式搜索的进化史

题目大意 添加链接描述 在3×3的棋盘上,摆有八个棋子,每个棋子上标有1至8的某一数字。棋盘中留有一个空格,空格用x来表示。空格周围的棋子可以移到空格中。要求解的问题是:给出一种初始布局(初始状态)和目标布局(为了使题目简单,设目标状态为12345678x),找到一种移动方法,实现从初始布局到目标布局的转变。如果不行输出unsolved。 思路分析 八数码问题的变化版,八数码的三种解法,无非是多了...

csyifanZhang的博客 565

深度优先搜索(Depth-First-Search)

一:深度优先搜索(Depth-First-Search) 从起点出发,走过的点要做标记,发现有没走过的点,就随意挑一个往前走,走不了就回退,此种路径搜索策略就称为“深度优先搜索”,简称“深搜”。 其实称为“远度优先搜索”更容易理解些。因为这种策略能往前走一步就往前走一步,总是试图走得更远。所谓远近(或深度),就是以距离起点的步数来衡量的。 1:判断从V出发是否能走到...

热爱阳光和自己 1448

简单算法bfs——百炼11:鸣人和佐助

11:鸣人和佐助 点击打开链接http://bailian.openjudge.cn/2016acm/11/ 总时间限制: 1000ms 内存限制: 65536kB 描述 佐助被大蛇丸诱骗走了,鸣人在多少时间内能追上他呢? 已知一张地图(以二维矩阵的形式表示)以及佐助和鸣人的位置。地图上的每个位置都可以走到,只不过有些位置上有大蛇丸的手下,需要先打败

curson_的博客 2871

pku 1077 Eight【八数码、广搜、hash判重】

pku 1077 Eight(八数码) (广搜+hash判重) /*memcpy(&t,s,sizeof(s))&t: 目标; s: 源 ; sizeof(s): 源内存出复制出的大小 作用:                               由s所指内存区域复制sizeof(s)个字节到t所指内存区域*/ /*memcmp(st[u],st[s],sizeof(st[

Beyyes 1238

百练6044--鸣人与佐助(BFS)

题目大意:又是迷宫啊迷宫啊。鸣人救佐助,一开始手上有一定数量的查克拉,路上遇见大蛇丸的手下,需要耗费一个查克拉杀死对方,才能继续走,然而鸣人能够瞬杀,不耗费时间,只消耗移动距离的时间。没有查克拉,就要避开大蛇丸的手下咯。求最短时间,不能就输出-1。 分析:BFS。每个格子需要记录三个数据,横纵坐标,以及查克拉数量,如果当前查克拉数量,不超过之前经过时的查克拉数量,那就不用走这一步,否则,仍然可以

Apple.Daily的专栏 3302

POJ - 1077 Eight

题意:经典八数码问题 思路:HASH+BFS#include #include #include #include using namespace std; const int MAXN = 500000; const int size = 1000003; typedef int State[9]; char str[30]; int state[9],goal[9]={1, 2,

那些年 1030

百练4115(鸣人和佐助)

题目链接:http://bailian.openjudge.cn/practice/4115/这次题面就不发出来了(有张图片),大家自行上网站搜索。这道题是一道变形的bfs题,也是迷宫问题。相较经典的迷宫问题,多了一个状态,就是查克拉的数量。(有木有感觉和新生赛的G题好像)。用map存点,用gg数组存每个点的状态判断可不可以走上代码#include &lt;iostream&gt; #includ...

star_moon0309的博客 438

poj1077Eight

Eight Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21880 Accepted: 9674 Special Judge Description The 15-puzzle has been around for over 100 years; even if...

ithome 193

OpenJ_Bailian - 4115 鸣人和佐助(book的三维标记:处理附加情况的搜索)

题目链接:https://vjudge.net/contest/347029#problem/M 分析: 从@到+,求最少时间,可以看成是找到一条最短路径。 dfs和bfs都是求最短路径的。dfs超时。 普通的bfs需要 book[i][j]来标记坐标(i,j) 是否走过。 但此题有附加条件,走#时,需要消耗一个查克拉,查克拉的数量决定了#是否能走。 单单的二维book数组已经不能满足要求。 ...

zaiyang遇见 1174
上一篇: POJ - 1724:ROADS
下一篇: 广搜与深搜的比较
朱事顺利、
博客等级 码龄9年 25粉丝 83原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

朱事顺利、

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值