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 ...
随机推荐
- 解决IntelliJ IDEA无法读取配置*.properties文件的问题
idea对这些配置的文件方式很明显和eclipse是不同的.在idea中有一个 Content Roots的概念.需要为每一个folder配置相应的Content Roots.Content Root ...
- Tessaract 源码分析(转)
源码分析 Page Layout 分析步骤 二值化算法: OTSU调用栈:main[api/tesseractmain.cpp] -> TessBaseAPI::ProcessPages[api ...
- HTML链接/实施CSS的三种方法
①页面内部链接: <head> <style type="text/css"> /*Cascading Style Shee ...
- Fragment add replace 区别
首先获取FragmentTransaction对象:FragmentTransaction transaction = getFragmentManager().beginTransaction(); ...
- Jetson tk1 刷机教程
前期准备: 1. Jetson TK1开发板. 2. 安装有ubuntu系统的PC(或者ubuntu虚拟机)切记:不管是PC还是虚拟机,务必确保有大于5G的存储空间,之后安装过程会作详细解释. 3 ...
- Linux内核基础设施
1.前言 本文主要介绍Linux内核实现的基本数据类型,包括链表,内核对象,内核对象引用计数,内核对象集合, 2.链表 1. 链表的基本结构 内核链表可以将任何类型的数据结构连接起来,链表结构如下: ...
- Mac环境变量配置错了以后初始化的方法
转自:https://blog.csdn.net/or_7r_ccl/article/details/50886223 配置过安卓开发环境,改过bash_profile这个文件,最后不知怎么的只有cd ...
- linux下混杂模式
混杂模式介绍: 混杂模式就是接收所有经过网卡的数据包,包括不是发给本机的包,默认情况下网卡只把发给本机的包(包括广播包)传递给上层程序,其它的包一律丢弃:简单的讲,混杂模式就是指网卡能接受所有通过它的 ...
- 读SRE Google运维解密有感(三)
前言 这是读“SRE Google运维解密”有感第三篇,之前的文章可访问www.addops.cn来查看.我们今天来聊聊“on call”也就是运维值班制度, 本人到目前为止也还在参与一线运维的值班, ...
- CentOS 6.5环境下heartbeat高可用集群的实现及工作原理详解
Linux HA Cluster高可用服务器集群,所谓的高可用不是主机的高可用,而是服务的高可用. 什么叫高可用:一个服务器down掉的可能性多种多样,任何一个可能坏了都有可能带来风险,而服务器离线通 ...