hdu 2722 Here We Go(relians) Again
来源:互联网 发布:sql条件查询语句 编辑:程序博客网 时间:2024/05/10 02:20
点击打开链接
/*Review :这题其实没什么难度,就是题目特别恶心,又臭又长,再加上制图也很恶心,第一次做这么恶心的题,于是乎拖了几个小时。把输入分为横向路 和 纵向路 来处理会比较方便一点,这个想了好久啊……好笨好笨*/----------------------------------------------------------------------------*/#include <stdio.h>#include <string.h>#define INF0x3f3f3f3f#define MAXN522#define min(x, y)((x) < (y) ? (x) : (y))#define max(x, y)((x) > (y) ? (x) : (y))#define MEM(a, v)memset (a, v, sizeof (a))boolused[MAXN] ;intv, h ;intdist[MAXN], map[MAXN][MAXN] ;int dijkstra (const int start, const int end){int i, j ;int iMinPath, MinPath ;MEM (used, 0) ;for (i = 1 ; i <= end ; ++i)dist[i] = map[start][i] ;dist[start] = 0 ;for (i = 1 ; i <= end ; ++i){iMinPath = 0 ;MinPath = INF ;for (j = 1 ; j <= end ; ++j){if (!used[j] && dist[j] < MinPath){iMinPath = j ;MinPath = dist[j] ;}}used[iMinPath] = 1 ;for (j = 1 ; j <= end ; ++j){if (!used[j])dist[j] = min(dist[iMinPath]+map[iMinPath][j], dist[j]) ;}}return dist[end] ;}int main (){int i, j ;int x, y, d, d1, d2, ver, hor ;int ret ;char c ;while (scanf ("%d%d", &v, &h), v | h){MEM (map, INF) ;ver = 1, hor = 1 ;for (i = 1 ; i <= 2 * v + 1 ; ++i){for (j = 1 ; j <= h + !(i&1) ; ++j){scanf ("%d %c", &d, &c) ;// 如果d为0,表示此路不通if (d == 0)c = 0 ;if (i & 1)// 横向的路{x = j + (h+1)*(hor-1) ;y = x + 1 ;d1 = (c == '*' || c == '>') ? 2520/d : INF ;d2 = (c == '*' || c == '<') ? 2520/d : INF ;}else// 纵向的路{x = j + (h+1)*(ver-1) ;y = j + (h+1)*(ver) ;d1 = (c == '*' || c == 'v') ? 2520/d : INF ;d2 = (c == '*' || c == '^') ? 2520/d : INF ;}map[x][y] = d1 ;map[y][x] = d2 ;}if (i & 1)++hor ;// 横向逢单加 1if (!(i & 1))++ver ;// 纵向逢双加 1getchar () ;}ret = dijkstra (1, (v+1)*(h+1)) ;if (INF == ret)printf ("Holiday\n") ;elseprintf ("%d blips\n", ret) ;}return 0 ;}
- Here We Go(relians) Again hdu 2722
- HDU 2722 Here We Go(relians) Again
- HDU 2722 Here We Go(relians) Again
- HDU 2722 Here We Go(relians) Again
- hdu 2722 Here We Go(relians) Again
- HDU-2722-Here We Go(relians) Again
- HDU 2722 Here We Go(relians) Again
- HDU 2722:Here We Go(relians) Again
- HDU 2722 Here We Go(relians) Again
- HDU 2722 Here We Go(relians) Again
- HDU 2722 Here We Go(relians) Again (输入处理恶心)
- HDU 2722 Here We Go(relians) Again 最短路
- 【最短路】 HDU 2722 Here We Go(relians) Again
- HDU 2722 Here We Go(relians) Again (SPFA+建图)
- Here We Go(relians) Again
- POJ 3653 Here We Go (relians) Again
- 【最短路+dijkstra+spfa】杭电 hdu 2722 Here We Go(relians) Again
- HDU 2722Here We Go(relians) Again(dijk最短路)
- Headless Android memory
- 防止重复提交
- word 2007 字号对应单倍行间距的磅值
- 文档关键词维护
- ORA-01031: 权限不足
- hdu 2722 Here We Go(relians) Again
- Build DCM4chee2
- Dialect does not support identity key generation
- c语言返回多个值——欧几里得算法的应用
- HIVE UDAF和UDTF实现group by后获取top值
- windows和linux杀死指定端口占用进程
- WSDL 三
- 文件权限与安全
- SecureCRT默认背景字体设置(适合敲命令的字体)