POJ1077 Eight —— 双向BFS

Open3D (C++) 使用点云创建数字高程模型DEM 阅读详情

主页面:http://blog.csdn.net/dolfamingo/article/details/77825569

(代码一直在精简完善……)



代码一:两个BFS, 两段代码; 用step控制“你一步, 我一步”。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <set>
#define ms(a,b) memset((a),(b),sizeof((a)))
using namespace std;
typedef long long LL;
const int INF = 2e9;
const LL LNF = 9e18;
const int MOD = 1e9+7;
const int MAXN = 1e6+10;

struct node
{
    int status;
    int s[9];
    int loc;
    int step;   //双向bfs需要记录第几步,才能做到“你一步,我一步”
};

int fac[9] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320};
int dir1[4][2] = { -1,0, 1,0, 0,-1, 0,1 };  //正方向
char op1[4] = {'u', 'd', 'l', 'r'  };
int dir2[4][2] = {0,1, 0,-1, 1,0, -1,0};    //反方向
char op2[4] = {'l', 'r', 'u', 'd'  };

char path1[MAXN], path2[MAXN];  //1为正方向,2为反方向,以下皆如此
int pre1[MAXN], pre2[MAXN];

int cantor(int s[])
{
    int sum = 0;
    for(int i = 0; i<9; i++)
    {
        int num = 0;
        for(int j = i+1; j<9; j++)
            if(s[j]<s[i])
                num++;
        sum += num*fac[8-i];
    }
    return sum+1;
}

queue<node>q1, q2;
int vis1[MAXN], vis2[MAXN];
int bfs(node now)
{
    ms(vis1,0);
    ms(vis2,0);
    while(!q1.empty()) q1.pop();
    while(!q2.empty()) q2.pop();

    now.status = cantor(now.s);
    now.step = 0;
    pre1[now.status] = -1;
    vis1[now.status] = 1;
    q1.push(now);

    for(int i = 0; i<9; i++)
        now.s[i] = i+1;
    now.loc = 8;
    now.status = cantor(now.s);
    now.step = 0;
    pre2[now.status] = -1;
    vis2[now.status] = 1;
    q2.push(now);

    int time = 0;   //计时器
    while(!q1.empty() || !q2.empty())
    {
        time++;
        while(!q1.empty())
        {
            if(q1.front().step==time)   //时间到了,就让给对方
                break;

            now = q1.front();
            q1.pop();

            if(vis2[now.status])    //此状态已被对方访问过,则说明两者“接上了”
                return now.status;

            int x = now.loc/3;
            int y = now.loc%3;
            for(int i = 0; i<4; i++)
            {
                int xx = x + dir1[i][0];
                int yy = y + dir1[i][1];
                if(xx>=0 && xx<=2 && yy>=0 && yy<=2)
                {
                    node tmp = now;
                    tmp.s[x*3+y] = tmp.s[xx*3+yy];
                    tmp.s[xx*3+yy] = 9;
                    tmp.status = cantor(tmp.s);
                    if(!vis1[tmp.status])
                    {
                        vis1[tmp.status] = 1;
                        tmp.loc = xx*3+yy;
                        tmp.step++;
                        path1[tmp.status] = op1[i];
                        pre1[tmp.status] = now.status;
                        q1.push(tmp);
                    }
                }
            }
        }

        while(!q2.empty())
        {
            if(q2.front().step==time)   //时间到了,就让给对方
                break;

            now = q2.front();
            q2.pop();

            if(vis1[now.status])    //此状态已被对方访问过,则说明两者“接上了”
                return now.status;

            int x = now.loc/3;
            int y = now.loc%3;
            for(int i = 0; i<4; i++)
            {
                int xx = x + dir2[i][0];
                int yy = y + dir2[i][1];
                if(xx>=0 && xx<=2 && yy>=0 && yy<=2)
                {
                    node tmp = now;
                    tmp.s[x*3+y] = tmp.s[xx*3+yy];
                    tmp.s[xx*3+yy] = 9;
                    tmp.status = cantor(tmp.s);
                    if(!vis2[tmp.status])
                    {
                        vis2[tmp.status] = 1;
                        tmp.loc = xx*3+yy;
                        tmp.step++;
                        path2[tmp.status] = op2[i];
                        pre2[tmp.status] = now.status;
                        q2.push(tmp);
                    }
                }
            }
        }
    }
    return -1;
}


void Print1(int status) //输出正方向的路径
{
    if(pre1[status]==-1) return;
    Print1(pre1[status]);
    putchar(path1[status]);
}

void Print2(int status) //输出反方向的路径
{
    if(pre2[status]==-1) return;
    putchar(path2[status]);
    Print2(pre2[status]);
}

int main()
{
    char tmp[50];
    while(gets(tmp))
    {
        node beg;
        int cnt = 0;
        for(int i = 0; tmp[i]; i++)
        {
            if(tmp[i]==' ') continue;
            if(tmp[i]=='x') beg.s[cnt] = 9, beg.loc = cnt++;
            else  beg.s[cnt++] = tmp[i]-'0';
        }
        int status = bfs(beg);
        if(status==-1)
            puts("unsolvable");
        else
        {
            Print1(status); Print2(status);   //输出路径
            putchar('\n');
        }
    }
}



代码二:两个BFS, 两段代码; 用队列的大小控制“你一步, 我一步”。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <set>
#define ms(a,b) memset((a),(b),sizeof((a)))
using namespace std;
typedef long long LL;
const int INF = 2e9;
const LL LNF = 9e18;
const int MOD = 1e9+7;
const int MAXN = 1e6+10;

struct node
{
    int status;
    int s[9];
    int loc;
};

int fac[9] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320};
int dir1[4][2] = { -1,0, 1,0, 0,-1, 0,1 };  //正方向
char op1[4] = {'u', 'd', 'l', 'r'  };
int dir2[4][2] = {0,1, 0,-1, 1,0, -1,0};    //反方向
char op2[4] = {'l', 'r', 'u', 'd'  };

char path1[MAXN], path2[MAXN];  //1为正方向,2为反方向,以下皆如此
int pre1[MAXN], pre2[MAXN];

int cantor(int s[])
{
    int sum = 0;
    for(int i = 0; i<9; i++)
    {
        int num = 0;
        for(int j = i+1; j<9; j++)
            if(s[j]<s[i])
                num++;
        sum += num*fac[8-i];
    }
    return sum+1;
}

queue<node>q1, q2;
int vis1[MAXN], vis2[MAXN];
int bfs(node now)
{
    ms(vis1,0);
    ms(vis2,0);
    while(!q1.empty()) q1.pop();
    while(!q2.empty()) q2.pop();

    now.status = cantor(now.s);
    pre1[now.status] = -1;
    vis1[now.status] = 1;
    q1.push(now);

    for(int i = 0; i<9; i++)
        now.s[i] = i+1;
    now.loc = 8;
    now.status = cantor(now.s);
    pre2[now.status] = -1;
    vis2[now.status] = 1;
    q2.push(now);

    while(!q1.empty() || !q2.empty())
    {
        int s1 = q1.size(); //当前队列中的结点步数是一样的,处理完这些结点,得到步数+1的结点
        while(s1--)
        {
            now = q1.front();
            q1.pop();

            if(vis2[now.status])    //此状态已被对方访问过,则说明两者“接上了”
                return now.status;

            int x = now.loc/3;
            int y = now.loc%3;
            for(int i = 0; i<4; i++)
            {
                int xx = x + dir1[i][0];
                int yy = y + dir1[i][1];
                if(xx>=0 && xx<=2 && yy>=0 && yy<=2)
                {
                    node tmp = now;
                    tmp.s[x*3+y] = tmp.s[xx*3+yy];
                    tmp.s[xx*3+yy] = 9;
                    tmp.status = cantor(tmp.s);
                    if(!vis1[tmp.status])
                    {
                        vis1[tmp.status] = 1;
                        tmp.loc = xx*3+yy;
                        path1[tmp.status] = op1[i];
                        pre1[tmp.status] = now.status;
                        q1.push(tmp);
                    }
                }
            }
        }

        int s2 = q2.size();
        while(s2--)
        {
            now = q2.front();
            q2.pop();

            if(vis1[now.status])    //此状态已被对方访问过,则说明两者“接上了”
                return now.status;

            int x = now.loc/3;
            int y = now.loc%3;
            for(int i = 0; i<4; i++)
            {
                int xx = x + dir2[i][0];
                int yy = y + dir2[i][1];
                if(xx>=0 && xx<=2 && yy>=0 && yy<=2)
                {
                    node tmp = now;
                    tmp.s[x*3+y] = tmp.s[xx*3+yy];
                    tmp.s[xx*3+yy] = 9;
                    tmp.status = cantor(tmp.s);
                    if(!vis2[tmp.status])
                    {
                        vis2[tmp.status] = 1;
                        tmp.loc = xx*3+yy;
                        path2[tmp.status] = op2[i];
                        pre2[tmp.status] = now.status;
                        q2.push(tmp);
                    }
                }
            }
        }
    }
    return -1;
}

void Print1(int status) //输出正方向的路径
{
    if(pre1[status]==-1) return;
    Print1(pre1[status]);
    putchar(path1[status]);
}

void Print2(int status) //输出反方向的路径
{
    if(pre2[status]==-1) return;
    putchar(path2[status]);
    Print2(pre2[status]);
}

int main()
{
    char tmp[50];
    while(gets(tmp))
    {
        node beg;
        int cnt = 0;
        for(int i = 0; tmp[i]; i++)
        {
            if(tmp[i]==' ') continue;
            if(tmp[i]=='x') beg.s[cnt] = 9, beg.loc = cnt++;
            else  beg.s[cnt++] = tmp[i]-'0';
        }
        int status = bfs(beg);
        if(status==-1)
            puts("unsolvable");
        else
        {
            Print1(status); Print2(status);   //输出路径
            putchar('\n');
        }
    }
}



代码三:两个队列,调用一段BFS(),用队列的大小控制“你一步, 我一步”。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <set>
#define ms(a,b) memset((a),(b),sizeof((a)))
using namespace std;
typedef long long LL;
const int INF = 2e9;
const LL LNF = 9e18;
const int MOD = 1e9+7;
const int MAXN = 1e6+10;

struct node
{
    int status;
    int s[9];
    int loc;
};

int fac[9] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320};
int dir[2][4][2] = { -1,0, 1,0, 0,-1, 0,1,   0,1, 0,-1, 1,0, -1,0};  //正方向
char op[2][4] = {'u', 'd', 'l', 'r' ,   'l', 'r', 'u', 'd'  };

char path[2][MAXN];
int pre[2][MAXN];

int cantor(int s[])
{
    int sum = 0;
    for(int i = 0; i<9; i++)
    {
        int num = 0;
        for(int j = i+1; j<9; j++)
            if(s[j]<s[i])
                num++;
        sum += num*fac[8-i];
    }
    return sum+1;
}

queue<node>q[2];
int vis[2][MAXN];
int bfs(int id)
{
    int Size = q[id].size();
    while(Size--)
    {
        node now = q[id].front();
        q[id].pop();

        if(vis[!id][now.status])
            return now.status;

        int x = now.loc/3;
        int y = now.loc%3;
        for(int i = 0; i<4; i++)
        {
            int xx = x + dir[id][i][0];
            int yy = y + dir[id][i][1];
            if(xx>=0 && xx<=2 && yy>=0 && yy<=2)
            {
                node tmp = now;
                tmp.s[x*3+y] = tmp.s[xx*3+yy];
                tmp.s[xx*3+yy] = 9;
                tmp.status = cantor(tmp.s);
                if(!vis[id][tmp.status])
                {
                    vis[id][tmp.status] = 1;
                    tmp.loc = xx*3+yy;
                    path[id][tmp.status] = op[id][i];
                    pre[id][tmp.status] = now.status;
                    q[id].push(tmp);
                }
            }
        }
    }
    return -1;
}

int solve(node now)     //把两个bfs缩在一起写, 精简代码
{
    ms(vis,0);
    while(!q[0].empty()) q[0].pop();
    while(!q[1].empty()) q[1].pop();

    now.status = cantor(now.s);
    pre[0][now.status] = -1;
    vis[0][now.status] = 1;
    q[0].push(now);

    for(int i = 0; i<9; i++)
        now.s[i] = i+1;
    now.loc = 8;
    now.status = cantor(now.s);
    pre[1][now.status] = -1;
    vis[1][now.status] = 1;
    q[1].push(now);

    int time = 0, ret;
    while(!q[0].empty() ||!q[1].empty())
    {
        ret = bfs(0);
        if(ret!=-1) return ret;
        ret = bfs(1);
        if(ret!=-1) return ret;
        time++;
    }
    return -1;
}

void Print1(int status) //输出正方向的路径
{
    if(pre[0][status]==-1) return;
    Print1(pre[0][status]);
    putchar(path[0][status]);
}

void Print2(int status) //输出反方向的路径
{
    if(pre[1][status]==-1) return;
    putchar(path[1][status]);
    Print2(pre[1][status]);
}

int main()
{
    char tmp[50];
    while(gets(tmp))
    {
        node beg;
        int cnt = 0;
        for(int i = 0; tmp[i]; i++)
        {
            if(tmp[i]==' ') continue;
            if(tmp[i]=='x') beg.s[cnt] = 9, beg.loc = cnt++;
            else  beg.s[cnt++] = tmp[i]-'0';
        }
        int status = solve(beg);
        if(status==-1)
            puts("unsolvable");
        else
        {
            Print1(status); Print2(status);   //输出路径
            putchar('\n');
        }
    }
}



代码四:一个队列(将正反两方向的结点都丢进同一个队列, 保证了“你一步我一步”), 一段BFS。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <set>
#define ms(a,b) memset((a),(b),sizeof((a)))
using namespace std;
typedef long long LL;
const int INF = 2e9;
const LL LNF = 9e18;
const int MOD = 1e9+7;
const int MAXN = 1e6+10;

struct node
{
    int status;
    int s[9];
    int loc;
    int id; //id标记正反方向
};

int fac[9] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320};
int dir[2][4][2] = { -1,0, 1,0, 0,-1, 0,1,   0,1, 0,-1, 1,0, -1,0};  //正方向
char op[2][4] = {'u', 'd', 'l', 'r' ,   'l', 'r', 'u', 'd'  };

char path[2][MAXN];
int pre[2][MAXN];

int cantor(int s[])
{
    int sum = 0;
    for(int i = 0; i<9; i++)
    {
        int num = 0;
        for(int j = i+1; j<9; j++)
            if(s[j]<s[i])
                num++;
        sum += num*fac[8-i];
    }
    return sum+1;
}

queue<node>que;
int vis[2][MAXN];
int bfs(node now)     //把两个bfs缩在一起写, 精简代码
{
    ms(vis,0);
    while(!que.empty()) que.pop();

    now.status = cantor(now.s);
    now.id = 0;
    pre[0][now.status] = -1;
    vis[0][now.status] = 1;
    que.push(now);

    for(int i = 0; i<9; i++)
        now.s[i] = i+1;
    now.loc = 8;
    now.status = cantor(now.s);
    now.id = 1;
    pre[1][now.status] = -1;
    vis[1][now.status] = 1;
    que.push(now);

    while(!que.empty())
    {
        node now = que.front();
        que.pop();

        if(vis[!now.id][now.status])
            return now.status;

        int x = now.loc/3;
        int y = now.loc%3;
        for(int i = 0; i<4; i++)
        {
            int xx = x + dir[now.id][i][0];
            int yy = y + dir[now.id][i][1];
            if(xx>=0 && xx<=2 && yy>=0 && yy<=2)
            {
                node tmp = now;
                tmp.s[x*3+y] = tmp.s[xx*3+yy];
                tmp.s[xx*3+yy] = 9;
                tmp.status = cantor(tmp.s);
                if(!vis[now.id][tmp.status])
                {
                    vis[now.id][tmp.status] = 1;
                    tmp.loc = xx*3+yy;
                    path[now.id][tmp.status] = op[now.id][i];
                    pre[now.id][tmp.status] = now.status;
                    que.push(tmp);
                }
            }
        }
    }
}

void Print1(int status) //输出正方向的路径
{
    if(pre[0][status]==-1) return;
    Print1(pre[0][status]);
    putchar(path[0][status]);
}

void Print2(int status) //输出反方向的路径
{
    if(pre[1][status]==-1) return;
    putchar(path[1][status]);
    Print2(pre[1][status]);
}

int main()
{
    char tmp[50];
    while(gets(tmp))
    {
        node beg;
        int cnt = 0;
        for(int i = 0; tmp[i]; i++)
        {
            if(tmp[i]==' ') continue;
            if(tmp[i]=='x') beg.s[cnt] = 9, beg.loc = cnt++;
            else  beg.s[cnt++] = tmp[i]-'0';
        }
        int status = bfs(beg);
        if(status==-1)
            puts("unsolvable");
        else
        {
            Print1(status); Print2(status);   //输出路径
            putchar('\n');
        }
    }
}





基于STM32L4XX、HAL库的IP101GRI以太网收发器(PHY)驱动程序设计 define IP101GRI_PHY_ADDRESS 0x01 // 根据硬件设计设置PHY地址。#define IP101GRI_PHYSTS 0x10 // PHY状态寄存器。#define IP101GRI_PHYINIR 0x12 // PHY中断寄存器。#define IP101GRI_PHYCR 0x14 // PHY控制寄存器。#define IP101GRI_PHYID2 0x03 // PHY标识符2。 阅读详情

相关推荐

PD虚拟机网络初始化失败的权限修复指南

本文针对Parallels Desktop虚拟机常见的“网络初始化失败”问题,提供了详细的权限修复指南。通过分析问题根源,指导用户安全备份并修改关键的`network.desktop.xml`和`dispatcher.desktop.xml`配置文件,以恢复PD虚拟机的网络连接。文章还包含了修复后的验证步骤及预防措施,帮助用户彻底解决并避免此类权限问题。

qqq44的博客 860

POJ 3131 Cubic Eight-Puzzle 双向BFS + HASH

超赞的一道搜索题,麻烦到没朋友,

自在飞花 936

Ubuntu20.04下运行VINS系列:VINS-Mono、VINS-Fusion和GVINS

安装好了VINS-Mono所需的ROS noetic、Eigen3.4.0、Ceres2.10和OpenCV4.2.0等。VINS-Mono是在ROS melodic以及Ceres1的环境下开发的,因此需要适配高版本的环境。

zardforever123的博客 2万+

POJ 1077 Eight(康拓展开 BFS 双向BFS)

题目:http://poj.org/problem?id=1077 题目大意:给你一个

沉溺的专栏 903

RM机器人麦轮底盘实战:从零搭建到PID调参全记录(附避坑指南)

本文详细记录了RM机器人麦轮底盘从零搭建到PID调参的全过程,涵盖硬件组装、开发环境搭建、底盘解算和PID调参等关键步骤,并附有实用的避坑指南。特别针对麦轮控制、底盘解算和电机调试等核心问题提供了专业解决方案,帮助开发者快速提升机器人性能。

bush的博客 400

STM32_DAC

DAC(Digital-to-Analog Converter,数模转换器)是将数字信号转换为模拟信号的外设,广泛应用于音频输出、波形生成、电机控制等场景。STM32F407 系列芯片配备了 2 个 DAC 通道(DAC1 和 DAC2),支持 12 位分辨率,支持多种触发方式,可输出稳定的模拟电压。本文从 DAC 的基本原理出发,详细讲解 STM32F407 DAC 的配置方法、代码实现、波形生成以及实际应用案例,帮助你快速掌握 DAC 的使用技巧。

轩宇的博客 1255

poj 1077(双向bfs)--- 未完待续

题目连接:http://poj.org/problem?id=1077 双向bfs: 参考文章:https://blog.csdn.net/DOLFAMINGO/article/details/77855491 前置知识:康拓展开 因为如果暴力搜索的话复杂度为9!,而时间只有1000ms,一定会T,所以这里可以利用双向bfs,当找到终点时结束。 代码: #include ...

积少成多,水滴石穿 253

Windows环境下IBSIMU的安装

本文主要介绍离子束仿真程序IBSIMU在Windows环境下的安装。

C_Tso的博客 3011

【启发式搜索】[POJ 1077]Eight

八数码问题,用的A*解决,但是数据太强A不了。。。TLE只能在POJ上先过一发了。 #include <cstdio> #include <algorithm> #include <cstring> #include <iostream> #include <vector> #include <queue&gt...

weixin_30519071的博客 142

复现《水化硅铝酸钙微结构和性能的分子动力学模拟研究》的分子动力学模拟

本文详细复现了杨军博士论文中关于水化硅铝酸钙(C-A-S-H)凝胶的分子动力学模拟方法。研究内容包括:1)基于11Å Tobermorite构建C-A-S-H分子模型,通过缺陷引入和Al掺杂调节Ca/Si比;2)使用ReaxFF力场模拟交联C-A-S-H的结构与力学性能;3)采用ClayFF力场研究纳米孔道中水和离子传输行为。研究提供了完整的LAMMPS输入脚本、Python分析代码和力场参数设置,为水泥基材料纳米尺度模拟提供可复现的技术方案。

huanghm88的专栏 118

自动驾驶领域自动化数据标注应用

自动驾驶领域自动化数据标注应用 1. 背景介绍 1.1 自动驾驶技术的发展 自动驾驶技术近年来取得了长足的进步,吸引了众多科技公司和传统车企的投入。自动驾驶系统需要感知周围环境、做出决策并控制车辆,是一个极具挑战的任务。其中,环境感知是自

AI天才研究院 2225

poj 3131 Cubic Eight-Puzzle (双向bfs+深度控制 立体八数码)

Cubic Eight-Puzzle Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 1344   Accepted: 451 Description Let’s play a puzzle using eight cubes placed on a 3 × 3

To be what you what to be! 2709

3D目标检测(PointPillars)(⭐⭐)—— 使用激光雷达点云检测车辆/行人/骑行者。技术栈:OpenPCDet、KITTI、Waymo数据集

OpenPCDet是由香港中文大学(深圳)和商汤科技联合开源的3D目标检测工具箱,基于PyTorch实现。它并非简单的代码库,而是一个模块化、可扩展的研究平台,目前支持超过15种主流算法(PointPillars、SECOND、PV-RCNN、PartA2、Voxel R-CNN等),并统一了KITTI、Waymo、nuScenes等数据集的接口。设计哲学Dataset:数据加载与预处理(点云读取、数据增强)Model:网络架构(支柱编码、骨干、检测头)Optimizer:优化器与学习率调度Tester。

2201_76125393的博客 38

poj 1077 Eight(双向bfs)

题目链接:http://poj.org/problem?id=1077 思路分析:题目要求在找出最短的移动路径,使得从给定的状态到达最终状态。 <1>搜索算法选择:由于需要找出最短的移动路径,所以选择bfs搜索 <2>判重方法: 将空格视为数字9,则可以将状态的集合视为1-9的排列组合的集合,根据康托展开,将每一个状态映射到一个正整数中; 在由哈希...

aqjh9999的博客 214

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

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

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

leekerian的博客 381

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

POJ1077、HDU1043 Eight 八数码问题:双向BFS、A*

Problem Address:http://poj.org/problem?id=1077 Problem Address:http://acm.hdu.edu.cn/showproblem.php?pid=1043 【前言】 第一次写八数码问题。 这份

Human_CK的专栏 1046

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

BFS之四(双向bfs和康托压缩)

/*双向BFS就是从起点 和 终点 同时开始搜索。由起点搜索(BSF1)得到的点标记为1,由终点搜索(BFS2)得到的点标记为2。当某一时刻BFS1搜索到了已经标记为2的点(或BFS2搜到了1号点),说明发生相遇,那么答案就是由bfs1和bfs2分别求得的两段路径长度的和。简单的分析:设每次的BFS,总的搜索状态数是r^L(r是搜索的分支数,L是搜索层数)。而采取双向BFS算法,那么,从前往后...

weixin_30563917的博客 168

POJ:1077 Eight(双向BFS+判重)

HDU也有这道题但是数据比较强,我的代码过不了(内存超限了。。)。只能过POJ的。。   这是某大神的。。 http://www.cnblogs.com/goodness/archive/2010/05/04/1727141.html     我的代码。。 用了stl这是速度慢的一个重要原因。。 #include #include #include #include #includ

Fighting 736

HDU 1043 && POJ 1077 Eight bfs || 双向bfs || A*搜索

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1043 http://poj.org/problem?id=1077题意:经典8数码问题,求出任意一个操作过程思路:首先进行逆序数判断,可以发现,在八数码中,交换两个相连的位置,整个八数码中逆序数的数量的奇偶性不变,而终态的逆序数的奇偶性是偶,所以开始时检查初始状态逆序数的奇偶性,为奇的话则无解。然后求解操

弱智就要多努力 313

POJ - 1077 Eight : 八数码 -- 哈唏 康托展开 双向bfs A* IDA*

前言 做完这道题,感觉整个人都完整了。 这道题所能涉及到的知识点特别多,列举如下: STL判重 Hash判重 康托展开 双向bfs A* IDA* 每一种知识点分别对应不同的版本,下面的题解按照以上顺序给出各个版本。 另外有个比较好的博客,可以根据这个博客给出的顺序一步一步实现代码,再此感谢此大牛博主。 点此转到 -> 八数码的八境界http:/

duaduac.com 1197

POJ 1077 Eight 【八数码问题、康托展开、双向BFS、反向BFS、打表】

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...

Code_U 354

Eight (HDU - 1043|POJ - 1077)(A* | 双向bfs+康拓展开)

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...

weixin_30369087的博客 177

poj-1077-Eight

Eight Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 21713   Accepted: 9607   Special Judge Description The 15-puzzle has been around for over 100 years; ev

u010211389的专栏 621

HDU 1043 Eight(经典八数码问题)对比POJ 1077(bfs)

题目链接:点击打开链接 事情是这样的,我先在TLE无数发之后A了POJ的1077,然后在VJ上看到“原题”,然而,此原题被我TLE5发MLE9发,最后从学长那里学得记录路径的方法之后才过,却原来,这道所谓原题并非原题!!!HDU 的1043和POJ的1077都叫Eight,但是由于HDU上是多组数据POJ上单组,所以POJ上直接正常bfs搜索, HDU上则需要预处理。。。 方法是一样的

Must so 958

POJ1077 Eight —— 经典的搜索问题

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1043 Eight Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 25408    Accepted Submiss

A man can be destroyed, but not defeated. 3463
上一篇: POJ1077 Eight —— 反向BFS
下一篇: POJ1077 Eight —— A*算法
DOLFAMINGO
博客等级 码龄10年 8粉丝 216原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值