Here We Go(relians) Again HDU2722
处理完输入就是很简单的一题 但是输入好难
勉强找到一种能看懂的。。。
#include<iostream>
#include<stdio.h>
#include<string>
#include<cstring>
using namespace std; #define MAX 999999999
#define N 501 int vis[N],map[N][N],dis[N];
int n,m; int Dijkstra(int start,int end)
{
int i,j,min,loc; memset(vis,,sizeof(vis));
for(i=;i<=end;i++)
dis[i]=map[start][i];
dis[start]=; for(i=;i<=end;i++)
{
min=MAX;
for(j=;j<=end;j++)
{
if(!vis[j]&&dis[j]<min)
{
min=dis[j];
loc=j;
}
}
vis[loc]=;
for(j=;j<=end;j++)
{
if(!vis[j]&&dis[loc]+map[loc][j]<dis[j])
dis[j]=dis[loc]+map[loc][j];
}
}
return dis[end];
} int main()
{
int i,j,ver,hor,d,x,y,d1,d2,ans;
char ch; //freopen("test.txt","r",stdin);
while(scanf("%d%d",&n,&m),n+m)
{
for(i=;i<=(n+)*(m+);i++)//共有(n+1)*(m+1)点
for(j=;j<=(n+)*(m+);j++)
map[i][j]=MAX; ver=;hor=; //若图中2*2的 则是3*3,节点是1-9,map[1][4]代表第一行指第二行的6
for(i=;i<=*n+;i++)
{
for(j=;j<=m+!(i&);j++)//偶数多一个输入
{
scanf("%d %c",&d,&ch);
if(d==)// 如果d为0,表示此路不通
ch=; if(i&)//奇数 横向的路
{
x=j+(m+)*(hor-);
y=x+;//横向的始终是[x][x+1]
d1=(ch=='*'||ch=='>')?/d:MAX;
d2=(ch=='*'||ch=='<')?/d:MAX;
}
else
{
x=j+(m+)*(ver-);//纵向的是[x][x+m+1]
y=j+(m+)*ver;
d1=(ch=='*'||ch=='v')?/d:MAX;
d2=(ch=='*'||ch=='^')?/d:MAX;
}
map[x][y]=d1;
map[y][x]=d2; }
if(i&) hor++; //横向加 1
else ver++;
}
ans=Dijkstra(,(n+)*(m+));//最后点数
if(MAX==ans)
printf("Holiday\n");
else
printf ("%d blips\n",ans);
}
return ;
}
Here We Go(relians) Again HDU2722的更多相关文章
- HDU 2722 Here We Go(relians) Again (spfa)
Here We Go(relians) Again Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/ ...
- Here We Go(relians) Again
Here We Go(relians) Again Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- CSU 1857 Crash and Go(relians)(模拟)
Crash and Go(relians) [题目链接]Crash and Go(relians) [题目类型]模拟 &题解: 这就是要严格的按照题意说的模拟就好了,也就是:每次添加进来一个圆 ...
- hdu 2722 Here We Go(relians) Again (最短路径)
Here We Go(relians) Again Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- 【HDOJ】2722 Here We Go(relians) Again
根据矩阵建图,然后求最短路径. #include <cstdio> #include <cstring> #include <cstdlib> #define L ...
- HDU 2722 Here We Go(relians) Again
最短路,建图太麻烦,略过…… #include <cstdio> #include <cstring> #include <queue> const int INF ...
- HDU 2722 Here We Go(relians) Again (最短路)
题目链接 Problem Description The Gorelians are a warlike race that travel the universe conquering new wo ...
- HDU--2722
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2722 分析:简单最短路,读入数据烦. #include<iostream> #includ ...
- POJ 3653 & ZOJ 2935 & HDU 2722 Here We Go(relians) Again(最短路dijstra)
题目链接: PKU:http://poj.org/problem? id=3653 ZJU:problemId=1934" target="_blank">http ...
随机推荐
- socket 聊天室
服务端: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; ...
- 阿里云3台机器组成集群配置ssh免密码登陆
1 查询阿里云局网ip 注意:需要配置同一地区同一可用区的机器 才是一个局网 2 配置好hosts文件 3 hostname确认也是正确的 4 生成公钥私钥 三台机器同样操作 ssh-keygen - ...
- POJ3233 Matrix Power Series(快速幂求等比矩阵和)
题面 \(solution:\) 首先,如果题目只要我们求\(A^K\) 那这一题我们可以直接模版矩乘快速幂来做,但是它现在让我们求$\sum_{i=1}^{k}{(A^i)} $ 所以我们思考一下这 ...
- Sql server 查询某个时间段,分布有几周,几月和几日
1. 查询:以“周”为单位 --查询以下时间段内分别有几周 --时间段:“2017-09-01”到“2017-10-1” select number as wknum from master..spt ...
- 2017-2018-2 20155303『网络对抗技术』Exp5:MSF基础应用
2017-2018-2 20155303『网络对抗技术』Exp5:MSF基础应用 --------CONTENTS-------- 一.原理与实践说明 1.实践内容 2.预备知识 3.基础问题 二.实 ...
- shiro自定义realm认证(五)
上一节介绍了realm的作用: realm:需要根据token中的身份信息去查询数据库(入门程序使用ini配置文件),如果查到用户返回认证信息,如果查询不到返回null.token就相当于是对用户输入 ...
- JS结合a标签的使用
a标签可以当作按钮使用,也可以当作连接. <a href=javascript:test(5)>弹出5</a> 会直接调用JS函数(注意中间没引号) <a href ...
- map_server地图服务器
http://wiki.ros.org/map_server 概述 map_server提供map_server ROS节点,它提供地图数据作为一个ROS服务器.也提供map_saver命令行功能,能 ...
- git入门与实践【转】
转自:http://www.cnblogs.com/shenhaocn/archive/2011/03/13/1982957.html 什么是版本控制 要了解什么是git,首先需要了解什么是版本控制( ...
- mysql系列六、mysql创建用户、授权、备份及恢复命令
一.创建用户和授权 下面的操作中,其中someusername为用户名,somepassword为密码,somedbname为数据库名 1.创建用户 create user 'someusername ...