HDU 1026 Ignatius and the Princess I BFS

四足机器人通用运动控制策略:强化学习与PD参数优化 运动控制是机器人实现稳定行走和复杂动作的核心技术,其关键在于精确调节关节的刚度和阻尼特性。PD控制器作为基础控制单元,通过比例(P)和微分(D)增益参数直接影响系统响应速度与稳定性。在四足机器人领域,强化学习(RL)通过模拟环境自主学习,能够有效解决传统控制方法难以适应不同形态机器人的痛点。该技术通过非对称Actor-Critic架构,结合状态估计网络和自适应参数采样策略,实现了跨平台的通用运动控制。典型应用包括工业检测、灾害救援等需要高适应性移动能力的场景,其中PD增益优化和形态参数自适应采样成为提升硬件 阅读详情
题意:从 (1,1) 到 (n,m) 最少要走多少秒?(如果方格上有数字,意思就是要停留多少秒?)
思路:BFS,对于方格上有数字的情况,把数字减1,然后再次加入队列,对于记录路径,我是 A[i][j] 代表到达 (i,j) 的前一个点,输出的时候从 A[n][m] 往前面找即可。
坑点:输出路径,烦的一匹。然而一遍过还是感觉萌萌哒。

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

/*********************************************
    Problem : HDU 1026
    Author  : NMfloat
    InkTime (c) NM . All Rights Reserved .
********************************************/

#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

#define rep(i,a,b)  for(int i = a ; i <= b ; i ++)
#define rrep(i,a,b) for(int i = b ; i >= a ; i --)
#define repE(p,u) for(Edge * p = G[u].first ; p ; p = p -> next)
#define cls(a,x)   memset(a,x,sizeof(a))
#define eps 1e-8

using namespace std;

const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5+5;
const int MAXE = 2e5+5;

typedef long long LL;
typedef unsigned long long ULL;

struct Node {
    int x,y,t,nt;
    int fromx,formy;
    Node() {}
    Node(int _x,int _y,int _t,int _nt,int _fromx,int _fromy) {x = _x;y = _y;t = _t;nt = _nt;fromx = _fromx ; formy = _fromy;}
}t[10005];

struct Point {
    int x,y;
    Point() {}
    Point(int _x,int _y) {x = _x;y = _y;}
}A[105][105];

Point root[225];

int T,n,m,k;

char Map[105][105];
char BMap[105][105];

int fx[] = {0,1,-1,0,0};
int fy[] = {0,0,0,1,-1};
int second ;

queue<Node>q;

bool BFS() {
    while(!q.empty())q.pop();
    q.push(Node(1,1,0,0,0,0));
    while(!q.empty()) {
        Node tmp = q.front();
        q.pop();
        if(tmp.x == n && tmp.y == m ) {
            second = tmp.t + tmp.nt;
            return true;
        }
        if(tmp.nt) {
            q.push(Node(tmp.x,tmp.y,tmp.t+1,tmp.nt-1,tmp.x,tmp.y)) ;
            continue;
        }
        rep(i,1,4) {
            int tmpx = tmp.x + fx[i]; int tmpy = tmp.y + fy[i];
            if(tmpx >= 1 && tmpx <= n && tmpy >= 1 && tmpy <= m) {
                if(Map[tmpx][tmpy] == '.')  {
                    q.push(Node(tmpx,tmpy,tmp.t+1,0,tmp.x,tmp.y));
                    A[tmpx][tmpy] = Point(tmp.x,tmp.y);
                } 
                else if(Map[tmpx][tmpy] == 'X') {

                }
                else {
                    q.push(Node(tmpx,tmpy,tmp.t+1,Map[tmpx][tmpy]-'0',tmp.x,tmp.y));
                    A[tmpx][tmpy] = Point(tmp.x,tmp.y);
                }
                Map[tmpx][tmpy] = 'X';
            }
        }
    }
    return false;
}

void input() {
    rep(i,1,n) scanf("%s",Map[i]+1) ;
    rep(i,1,n) rep(j,1,m) {
        BMap[i][j] = Map[i][j];
    }
}

void solve() {
    if(BFS()) {
        int tmpx,tmpy,x0,y0;
        int tot = 1;
        tmpx = n ; tmpy = m ; 
        root[tot++] = Point(tmpx,tmpy);
        while(tmpx != 1 || tmpy != 1) {
            x0 = A[tmpx][tmpy].x ; y0 = A[tmpx][tmpy].y;
            tmpx = x0 ; tmpy = y0;
            root[tot++] = Point(tmpx,tmpy);
        }
        printf("It takes %d seconds to reach the target position, let me show you the way.\n",second);
        second = 1;
        rrep(i,1,tot-1) {
            if(i == 1) {
                while(BMap[root[i].x][root[i].y] > '0') {
                    printf("%ds:FIGHT AT (%d,%d)\n",second++,root[i].x-1,root[i].y-1);
                    BMap[root[i].x][root[i].y] -- ;
                }
                break;
            }
            if(BMap[root[i].x][root[i].y] != '.') {
                while(BMap[root[i].x][root[i].y] > '0') {
                    printf("%ds:FIGHT AT (%d,%d)\n",second++,root[i].x-1,root[i].y-1);
                    BMap[root[i].x][root[i].y] -- ;
                }
            }
            printf("%ds:(%d,%d)->(%d,%d)\n",second++,root[i].x-1,root[i].y-1,root[i-1].x-1,root[i-1].y-1);
        }
    }
    else puts("God please help our poor hero.");
    puts("FINISH");
}

int main(void) {
    //freopen("a.in","r",stdin);
    //scanf("%d",&T); while(T--) {
    while(~scanf("%d %d",&n,&m)) {
    //while(scanf("%d",&n),n) {
        input();
        solve();
    }
    return 0;
}
AD9914数字斜坡模式使用 类似的,如果DRG输出处于负斜率斜坡中间,DRCTL引脚由逻辑0变为逻辑1,那么DRG会立即切换成正斜率参数,恢复在两个限值之间振荡输出。当两个非驻留位同时设置时,每次DRG输出达到编程设定的上限值或下限值后(假定DRG过输出使能位(0x01[13])已设置),DROVER信号会产生一个正脉冲(两个DDS时钟周期)。不过,在非驻留操作中,DRG输出不一定保持在上下限值。例如,设置数字斜坡非驻留高位,则当达到上限值时,DRG会自动(立即)跳到下限值(这一过程并非以斜坡方式返回下限值,而是直接跳至下限值)。 阅读详情

相关推荐

Unity 实现动态网格地图生成与交互组件

本文详细介绍了在Unity中实现动态网格地图生成与交互组件的完整方案。从基础网格单元实现到高级交互功能,涵盖网格生成器核心逻辑、事件驱动架构、性能优化技巧以及六边形网格等特殊实现。特别适合游戏开发者学习如何构建战棋、模拟经营类游戏的可交互地图系统,提升开发效率与用户体验。

weixin_29015483的博客 1068

HDU1026 Ignatius and the Princess I BFS

Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 22883 Accepted Submission(s): 7378 Special Judge Problem Descrip...

DouglasConnor的博客 547

Mendix 开发实践指南|Mendix平台概览

低代码开发是一种将编码从文本形式转变为视觉形式的应用开发方法。它提供了一个模型驱动的、拖放式的界面,而不是传统的编码环境,使得各种技能水平的开发者——包括专业开发人员、新手、主题专家、业务利益相关者和决策者——都能使用低代码工具来构建驱动价值的企业业务应用。低代码的核心在于提高开发的可访问性和效率,让更多人能够参与到应用开发中来​​。Mendix适用于多种应用场景,包括企业级应用、移动应用、物联网(IoT)应用和微服务架构等。

多年搬砖的经验分享... 4413

hdu1026 Ignatius and the Princess I (bfs)

Ignatius and the Princess I Problem Description The Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has to rescue our pretty Princess. Now he gets into feng5166's castle. The castle is a large labyrinth. To make the problem simply,

just_for_your_smile的专栏 1万+

FDTD Solutions-入射波长模式

经常在文献中看到仿真光源使用TM/TE模式,这个确定是十分必要的,决定了仿真结果。 但是也不能局限于选择TM/TE,因为不同领域、不同软件之间的使用习惯和命名可能不同。并且在现代光波导器件中,几乎全部 都是混合模式,或者称之为quasi-TE(准TE模式)和quasi-TM(准TM模式),多数情况下都简称为TE模式和TM模式。要知道 到底是TE模式还是TM模式,需要查看其电场的主分量(即振幅...

HECHUANWANG的博客 1万+

【表面缺陷检测】基于yolov5的钢轨表面缺陷检测(附代码和数据集,Windows系统)

【表面缺陷检测】基于yolov5的钢轨表面缺陷检测(附代码和数据集,Windows系统)

学无止境、积少成多、厚积薄发 3983

ACM-BFS之Ignatius and the Princess I ——hdu1026

BFS 优先队列 hdu1026

继续激情,继续奋斗。 1530

[深入研究4G/5G/6G专题-31]: 5G NR开机流程5.2 - UE Attach流程(Registeration Request/Accept/Complete)

目录前言:前置条件:第1章 5G NR UE attach流程(从UE log的视角看)1.0 NAS消息解析器1.1 消息交互流程1.2 UE Registeration Request消息(AMF->基站->UE)1.3 AMF Registeration Accept消息(AMF->基站->UE)1.4 UE Register complete消息(UE->基站->AMF)第2章 UE Register...............

文火冰糖(王文兵)的博客 7万+

HDU 1026 Ignatius and the Princess I (BFS+优先队列)

HDU 1026 Ignatius and the Princess I (BFS+优先队列)Problem Description The Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has to rescue our pretty Princess. Now he gets into fen

退役的铜牌狗 385

【软考高项论文】论信息系统项目管理的干系人绩效域

例如,在处理与电信运营商合作铺设光纤网络的问题时,考虑到其在通信设施建设和运维方面的专业性和重要性,我们将之定位为高权力高利益的干系人,给予了高度关注和优先沟通。项目全程,我们对干系人绩效域的执行效果进行了定期检查和评估,通过定量与定性的数据收集,确认了项目在干系人管理上的成效,具体表现为:建立了稳固的工作关系网络,使干系人普遍认可项目目标;鉴于本项目牵涉到政府各级部门、企事业单位、市民团体、技术研发伙伴等多种类型的干系人,且干系人的诉求和影响力各异,因此,有序且持续的干系人参与管理显得尤为关键。

Programming Talk 1681

清华源pip install出现ERROR: Could not find a version that satisfies the requirement的解决方案

本文主要介绍了清华源pip install出现ERROR: Could not find a version that satisfies the requirement的解决方案,希望能对学习python的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 8万+

hdu 1026 Ignatius and the Princess I bfs

用到了图论最短路更新的思想,当走到走过的地方时要更新 数据: 5 6 .XX.1. ..X.6. 2...X. ...XX. XXXXX. View Code #include <stdio.h>#include <string.h>#include <queue>using namespace std;struct node{...

diaopi1575的博客 148

【XSRP软件无线电】基于软件无线电平台的QPSK频带通信系统设计(含有完整工程资料获取链接)

软件无线电(Software Defined Radio, SDR)是一种无线通信系统,它通过软件来定义和实现无线电的功能,而不是依赖于传统的硬件电路。SDR平台的核心思想是将传统无线电系统中的大部分硬件功能,如调制解调、信号处理、频率选择等,通过软件来实现。这种设计理念使得SDR具有高度的灵活性和可重配置性,能够适应不同的通信标准和频段,快速适应新的通信技术。

嵌入式技术开发 3281

【Bfs】HDU 1026 Ignatius and the Princess I

直接贴代码好了。。。感觉Bfs的重点只是在于理清 #include #include #include #include #include using namespace std; int n,m,cont; char mp[105][105]; //记录地图 struct { int x,y,d; int before; }q[10000007],

曜雨丶的博客 401

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

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

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

HDU 1026 Ignatius and the Princess I BFS 优先队列

Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 18557    Accepted Submission(s): 5976 Special Judge Problem

LZK1997的博客 887

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

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

hdu1026 Ignatius and the Princess I(bfs+路径)

http://acm.hdu.edu.cn/showproblem.php?pid=1026 题意:求最短路长度、路径,有打怪操作,同样在路径中输出。 思路:很好的练习题吧,今天(2016/10/24)第二次做,打怪地方的标记初始化放在了结构体中,半天找不出错。好在改好了,1A~。 #include #include #include #include #incl

Iguodala的博客 432

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

HDU1026 Ignatius and the Princess I BFS+路径输出

要求最短时间,使用BFS,使用优先队列,将时间少的放到堆顶。先出堆。 然后由于要输出路径,在节点中加入PRE,设计的数据结构不同这里的方法也不一样,可以将矩阵中的点作为节点,那么就有prex,prey,如果像我一样单个节点作为队列中的元素,则要记录节点编号,我的方法有点麻烦,推荐直接记录x,y的方法。   Ignatius and the Princess I Time Limit: 20

1442

HDU1026 Ignatius and the Princess I(BFS)

Problem Description The Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has to rescue our pretty Princess. Now he gets into feng5166’s castle. The castle is a large labyrinth.

oyasherkin的博客 311

hdu 1026(Ignatius and the Princess I)BFS

Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17930Accepted Submission(s): 5755Special Judge Problem De...

anque1234的博客 133

hdu 1026 Ignatius and the Princess I(bfs搜索+输出路径)

题目来源:hdu-1026 Ignatius and the Princess I Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 14677 Accepted Submi

暮光乐鱼的博客 1102

HDU 1026 Ignatius and the Princess I (BFS)

Problem Description The Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has to rescue our pretty Princess. Now he gets into feng5166's castle. The castle is a lar...

bandiaodai5734的博客 122

hdu1026 Ignatius and the Princess I BFS

http://acm.hdu.edu.cn/showproblem.php?pid=1026 Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9535    A

天亮说晚安 1687

HDU 1026 Ignatius and the Princess I (BFS,路径输出)

Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 22707    Accepted Submission(s): 7314Special Judge   Problem Desc...

YIU 259

hdu 1026 Ignatius and the Princess I(bfs)

Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 16269    Accepted Submission(s): 5164 Special Judge Problem

lym77777的博客 394

HDU1026:Ignatius and the Princess I(BFS)

问题描述: Problem Description The Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has to rescue our pretty Princess. Now he gets into feng5166’s castle. The castle is a large laby

ww的博客 258

Ignatius and the Princess I(bfs+记录路径)hdu 1026

Ignatius and the Princess ITime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Special JudgeProblem DescriptionThe Princess has been abducted by the BEelzebub feng5166, ...

ljyanjy 332
上一篇: HDU 1029 Ignatius and the Princess IV 水题
下一篇: HDU 1027 Ignatius and the Princess II 全排列
_NMfloat_
博客等级 码龄12年 7粉丝 315原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值