Enterprising Escape

本文介绍了一个迷宫逃脱问题的解决方案,使用优先队列实现最短路径寻找,通过击败不同类型的敌人到达边界。文章包含完整的C++代码实现,适用于算法学习和技术挑战。
</pre><table width="100%" bgcolor="#ffffff"><tbody><tr><td align="center"><strong>Time Limit: </strong>20000ms, <strong>Special Time Limit:</strong>50000ms, <strong>Memory Limit:</strong>65536KB</td></tr><tr><td align="center"><strong>Total submit users:</strong> 28, <strong>Accepted users: </strong>18</td></tr><tr><td align="center"><strong>Problem 12921 : </strong><span style="color:#0000ff;">No special judgement</span></td></tr><tr><td><span style="font-size:14px;color:#0000aa;"><strong>Problem description</strong></span></td></tr><tr><td class="title"><p>The Enterprise is surrounded by Klingons! Find the escape route that has the quickest exit time, and print that time.Input is a rectangular grid; each grid square either has the Enterprise or some class of a Klingon warship. Associated with each class of Klingon warship is a time that it takes for the Enterprise to defeat that Klingon. To escape, the Enterprise must defeat each Klingon on some path to the perimeter. Squares are connected by their edges, not by corners (thus, four neighbors). </p></td></tr><tr><td><span style="font-size:14px;color:#0000aa;"><strong>Input</strong></span></td></tr><tr><td><p>The first line will contain T, the number of cases; 2 ≤ T ≤ 100. Each case will start with line containing three numbers k, w, and h. The value for k is the number of different Klingon classes and will be between 1 and 25, inclusive. The value for w is the width of the grid and will be between 1 and 1000, inclusive. The value for h is the height of the grid and will be between 1 and 1000, inclusive.Following that will be k lines. Each will consist of a capital letter used to label the class of Klingon ships followed by the duration required to defeat that class of Klingon. The label will not be “E”. The duration is in minutes and will be between 0 and 100,000, inclusive. Each label will be distinct.Following that will be h lines. Each will consist of w capital letters (with no spaces between them). There will be exactly one “E” across all h lines, denoting the location of the Enterprise; all other capital letters will be one of the k labels given above, denoting the class of Klingon warship in the square. </p></td></tr><tr><td><span style="font-size:14px;color:#0000aa;"><strong>Output</strong></span></td></tr><tr><td><p>Your output should be a single integer value indicating the time required for the Enterprise to escape. </p></td></tr><tr><td><span style="font-size:14px;color:#0000aa;"><strong>Sample Input</strong></span></td></tr><tr><td><pre>2
6 3 3
A 1
B 2
C 3
D 4
F 5
G 6
ABC
FEC
DBG
2 6 3
A 100
B 1000
BBBBBB
AAAAEB
BBBBBB
Sample Output
2
400
#include<iostream>//E题迷宫。。。不过呀。。。喵 
#include<cstring>//s用优先队列写的,应该还有其他方法吧,迷宫题型bfs之类的 
#include<cstdlib>//原理不明,还不能收进去 
#include<queue>//输入很巧 
#include<vector>//最后的memset初始化有问题 
#define maxn 1010
#include<algorithm>
#define INF 999999999
#define ll int
using namespace std;
int strx,stry;
char s[maxn][maxn];
char str[5];
int num[30];
int k,w,h;
//bool vis[1000010];
int numdp[1010*1010];
bool vis[maxn][maxn];
int v[4]={-1,1,0,0};
int e[4]={0,0,1,-1};
int result;

  	
struct cmp
{
    bool operator()(int x, int y)
    {
        return numdp[x] > numdp[y];
    }
};


int main()
{
    int cas;
    scanf("%d",&cas);
    while(cas--)
    {
        
        scanf("%d%d%d", &k, &w, &h);
        memset(num, 0, sizeof(num));
        for(int i = 0; i < k; i++)
        {
        	int x;
            scanf("%s%d", str, &x);//一输输一行取始个 
            num[str[0] - 'A'] = x;//超巧 
        }
        for(int i = 0; i < h; i++)
            scanf("%s", s[i]);//学习中 
            strx = stry = -1;
        
        for(int i=0;i<h;i++)
        {
            for(int j=0;j<w;j++)
            {
                if(s[i][j]=='E')
                {
                strx=i;
                stry=j;
                break;
                }
            }
        }
        memset(vis, 0, h*1010);
        memset(numdp, 0, h*1010*sizeof(int));
        vis[strx][stry] = true;//学习了 
        priority_queue<int, vector<int>, cmp>q;
	 int z=(strx)*w+stry;
     numdp[z] = 0;
	 q.push(z);
	 while(!q.empty())
	 {
	 int tep=q.top();
	 q.pop();
	 int x=tep/w;
	 int y=tep%w;
	 if(x==0 || x==(h-1) || y==0 || y==(w-1))
	 {
	 	result=numdp[tep];
	 	break;
	 }
	 for(int i=0;i<4;i++)
	 {
	 	int newx=x+v[i];int newy=y+e[i];
	if(!vis[newx][newy] && newx>-1 && newx<h && newy>-1 && newy<w )
		{
		    int newz=newx*w+newy;
			numdp[newz]=numdp[tep]+num[s[newx][newy] - 'A'];
			q.push(newz);
			vis[newx][newy]=true;
			
		} 
	 }
	 
	 }
	 cout<<result<<endl; 
    }
    return 0;
}



内容概要:本文档围绕六自由度机械臂的ANN人工神经网络设计展开,涵盖正向与逆向运动学求解、正向动力学控制,并采用拉格朗日-欧拉法推导逆向动力学方程,所有内容均通过Matlab代码实现。同时结合RRT路径规划与B样条优化技术,提升机械臂运动轨迹的合理性与平滑性。文中还涉及多种先进算法与仿真技术的应用,如状态估计中的UKF、AUKF、EKF等滤波方法,以及PINN、INN、CNN-LSTM等神经网络模型在工程问题中的建模与求解,展示了Matlab在机器人控制、智能算法与系统仿真中的强大能力。; 适合人群:具备一定Ma六自由度机械臂ANN人工神经网络设计:正向逆向运动学求解、正向动力学控制、拉格朗日-欧拉法推导逆向动力学方程(Matlab代码实现)tlab编程基础,从事机器人控制、自动化、智能制造、人工智能等相关领域的科研人员及研究生;熟悉运动学、动力学建模或对神经网络在控制系统中应用感兴趣的工程技术人员。; 使用场景及目标:①实现六自由度机械臂的精确运动学与动力学建模;②利用人工神经网络解决传统解析方法难以处理的非线性控制问题;③结合路径规划与轨迹优化提升机械臂作业效率;④掌握基于Matlab的状态估计、数据融合与智能算法仿真方法; 阅读建议:建议结合提供的Matlab代码进行实践操作,重点理解运动学建模与神经网络控制的设计流程,关注算法实现细节与仿真结果分析,同时参考文中提及的多种优化与估计方法拓展研究思路。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值