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 ...
随机推荐
- js scroll函数
$(function () { $(".sticky").hide(); var top = $(window).scrollTop(); if (top >= 100) { ...
- Postfix 邮件服务 - roundcube webmail
roundcubemail作为web端的邮件客户端.是一个基于浏览器,支持多国语言的IMAP客户端,它的操作界面看起像一个桌面应用程序.它提供一个email客户端应该具备的所有功能,包括MIME支 ...
- JavaScript之小工具之日志log()[兼容]
function log(){ try{ console.log.apply(console,arguments); }catch(e){ try{ opera.postError.apply(ope ...
- Linux 之【辨析UPDATE/UPGRADE】和安装/卸载软件(apt-get)
一.[辨析UPDATE/UPGRADE] UPDATE: update is used to download package information from all configured sour ...
- “微信小程序商城构建全栈应用”开发小记
注意事项: 1.application\api\extra下的wx.php记得填写小程序的app_id.app_secret: 2.API测试小工具需要APPID:
- (原创 开源)AppWidge的使用—桌面便利贴
Android平台的一大特色就是支持桌面插件——AppWidget. 且不说,AppWidget是否会影响系统的流畅性,AppWidget确实是满足了用户个性化和快捷操作的需要. 常见的AppWidg ...
- 关于apache 开启 ssl https 支持 TLS1.2 的些事
项目背景 需要搭建一个小程序的服务器,当然要使用https协议服务器windows service 2012 r2,后台语言是php,服务集成环境装的是appserv2.5 ,apache2.2证书申 ...
- Eclipse通用设置
分类 Eclipse分为64位.32位,安装版.免安装版 查看Eclipse版本信息 Help - About Eclipse - Installation Details
- Python2和Python3中print的不同点
在Python2和Python3中都提供print()方法来打印信息,但两个版本间的print稍微有差异 主要体现在以下几个方面: 1.python3中print是一个内置函数,有多个参数,而pyth ...
- WPS 表格筛选两列相同数据-完美-2017年11月1日更新
应用: 1.选出A列中的数据是否在B列中出现过: 2.筛选出某一批序号在一个表格里面的位置(整批找出) 3.其实还有其他很多应用,难描述出来... ... A列中有几百的名字,本人想帅选出B列中的名字 ...