HDU--2722

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2722

分析:简单最短路,读入数据烦。

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<cmath>
 5 #include<algorithm>
 6 #include<queue>
 7 #include<vector>
 8 #define maxn 450
 9 #define inf 0xfffffff
10 using namespace std;
11 int blip[maxn];
12 int n,m;
13 bool vis[maxn];
14 struct edge
15 {
16     int to,w;
17     edge(int x,int y)
18     {
19         to=x;w=y;
20     }
21 };
22 vector<edge>e[maxn];
23 queue<int>q;
24 void spfa(const int s)
25 {
26     while(!q.empty())q.pop();
27     for(int i=0;i<(n+1)*(m+1);i++)
28     {
29         vis[i]=false;
30         blip[i]=inf;
31     }
32     vis[s]=true;blip[s]=0;
33     q.push(s);
34     while(!q.empty())
35     {
36         int u=q.front();q.pop();
37         for(int i=0;i<e[u].size();i++)
38         {
39             if(blip[e[u][i].to]>blip[u]+e[u][i].w)
40             {
41                 blip[e[u][i].to]=blip[u]+e[u][i].w;
42                 if(!vis[e[u][i].to])
43                 {
44                     vis[e[u][i].to]=true;
45                     q.push(e[u][i].to);
46                 }
47             }
48         }
49         vis[u]=false;
50     }
51 }
52 int main()
53 {
54     while(~scanf("%d%d",&n,&m))
55     {
56         if(n==0||m==0)break;
57         for(int i=0;i<maxn;i++)e[i].clear();
58         for(int i=0;i<=2*n;i++)
59         {
60             int pp=m;if(i&1)pp++;
61             for(int j=0;j<pp;j++)
62             {
63                 int v;char c;int tmp;
64                 scanf("%d %c",&v,&c);
65                 if(v!=0)
66                 {
67                     if(c=='*'&&i%2==0)
68                     {
69                         tmp=i/2*(m+1)+j;
70                         e[tmp].push_back(edge(tmp+1,2520/v));
71                         e[tmp+1].push_back(edge(tmp,2520/v));
72                     }
73                     else if(c=='*'&&(i&1))
74                     {
75                         tmp=i/2*(m+1)+j;
76                         e[tmp].push_back(edge(tmp+m+1,2520/v));
77                         e[tmp+m+1].push_back(edge(tmp,2520/v));
78                     }
79                     else if(c=='>')e[i/2*(m+1)+j].push_back(edge(i/2*(m+1)+j+1,2520/v));
80                     else if(c=='<')e[i/2*(m+1)+j+1].push_back(edge(i/2*(m+1)+j,2520/v));
81                     else if(c=='v')e[i/2*(m+1)+j].push_back(edge(i/2*(m+1)+j+m+1,2520/v));
82                     else if(c=='^')e[i/2*(m+1)+j+m+1].push_back(edge(i/2*(m+1)+j,2520/v));
83                 } 
84             }
85         }
86         spfa(0);
87         if(blip[(n+1)*(m+1)-1]==inf)cout<<"Holiday\n";
88         else printf("%d blips\n",blip[(n+1)*(m+1)-1]);
89     }
90     return 0;
91 }
View Code

 

转载于:https://www.cnblogs.com/i-love-acm/p/3288470.html

Rebuild started: Project: Project *** Using Compiler &#39;V6.22&#39;, folder: &#39;E:\Keil_v5\ARM\ARMCLANG\Bin&#39; Rebuild target &#39;Target 1&#39; assembling startup_stm32f10x_md.s... Start/core_cm3.c(445): error: non-ASM statement in naked function is not supported 445 | uint32_t result=0; | ^ Start/core_cm3.c(442): note: attribute is here 442 | uint32_t __get_PSP(void) __attribute__( ( naked ) ); | ^ Start/core_cm3.c(465): error: parameter references not allowed in naked functions 465 | "BX lr \n\t" : : "r" (topOfProcStack) ); | ^ Start/core_cm3.c(461): note: attribute is here 461 | void __set_PSP(uint32_t topOfProcStack) __attribute__( ( naked ) ); | ^ Start/core_cm3.c(479): error: non-ASM statement in naked function is not supported 479 | uint32_t result=0; | ^ Start/core_cm3.c(476): note: attribute is here 476 | uint32_t __get_MSP(void) __attribute__( ( naked ) ); | ^ Start/core_cm3.c(499): error: parameter references not allowed in naked functions 499 | "BX lr \n\t" : : "r" (topOfMainStack) ); | ^ Start/core_cm3.c(495): note: attribute is here 495 | void __set_MSP(uint32_t topOfMainStack) __attribute__( ( naked ) ); | ^ 4 errors generated. compiling core_cm3.c... compiling misc.c... compiling system_stm32f10x.c... compiling stm32f10x_adc.c... compiling stm32f10x_dac.c... compiling stm32f10x_exti.c... compiling stm32f10x_dbgmcu.c... compiling stm32f10x_dma.c... compiling stm32f10x_crc.c... compiling stm32f10x_cec.c... compiling stm32f10x_bkp.c... compiling stm32f10x_can.c... compiling stm32f10x_flash.c... compiling stm32f10x_pwr.c... compiling stm32f10x_fsmc.c... compiling stm32f10x_
03-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值