找朋友
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
X,作为户外运动的忠实爱好者,总是不想呆在家里。现在,他想把死宅Y从家里拉出来。问从X的家到Y的家的最短时间是多少。
为了简化问题,我们把地图抽象为n*n的矩阵,行编号从上到下为1 到 n,列编号从左到右为1 到 n。矩阵中’X’...
分类:
其他好文 时间:
2014-08-12 17:19:54
阅读次数:
277
ZOJ 1649 && HDU 1242 Rescue 大半夜写博客也是蛮拼的。。...
分类:
其他好文 时间:
2014-08-12 10:28:23
阅读次数:
182
Problem Description
Let's play a card game called Gap.
You have 28 cards labeled with two-digit numbers. The first digit (from 1 to 4) represents the suit of the card, and the second digit (from 1 ...
分类:
其他好文 时间:
2014-08-12 10:24:14
阅读次数:
379
Problem Description
This is a simple game.The goal of the game is to roll two balls to two holes each.
'B' -- ball
'H' -- hole
'.' -- land
'*' -- wall
Remember when a ball rolls into a hole, the...
分类:
其他好文 时间:
2014-08-11 21:22:12
阅读次数:
308
EK Template :bool bfs(int src, int des){ memset(pre, -1, sizeof(pre)); while(!que.empty()) que.pop(); pre[src] = 0; int index; que.push...
分类:
Web程序 时间:
2014-08-11 21:15:52
阅读次数:
268
Red and BlackTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9684Accepted Submission(s): 6021Probl...
分类:
其他好文 时间:
2014-08-11 20:53:12
阅读次数:
286
题意:
给出一个迷宫,‘#’是墙壁,‘ ’(空格)可走,‘S’是起点,‘A’是目标,一个群体从S点开始,每次可以走周围相邻的4个格子,走到某个目标的花费是从上一个目标(或起点)开始计算的步数,群体可且仅可在S或A出分成若干个(可以看成是无数个,即使在同一个格子中)群体。比如从S开始走5步到A1,在A1分成两个群体,其中一个到达A2走3步,另一个到达A3也走3步,那么总花费是5+3+3=11。求到达所有A的最小花费。
分析:
题意很难理解,其实就是个最小生成树,用BFS在平面内模拟prim算法即可,这里要用到...
分类:
其他好文 时间:
2014-08-11 17:55:02
阅读次数:
268
1 #include 2 #include 3 #include 4 #include 5 #define M 205 6 #define INF 0x3f3f3f3f 7 using namespace std; 8 9 int map[M][M];10 int d[M], vis[M];11.....
分类:
其他好文 时间:
2014-08-11 14:57:22
阅读次数:
276
本题可以使用BFS和DFS解题,也可以构建图,然后利用Dijsktra解题。
不过因为数据很少,就没必要使用Dijsktra了。
BFS和DFS效率都是一样的,因为都需要搜索所有可能的路径,并记录最短路径和当前路径。
推荐使用DFS,感觉会方便很多,BFS会麻烦很多,因为需要记录并比较路径。
#include
#include
#include
const int MAX_...
分类:
其他好文 时间:
2014-08-11 12:08:02
阅读次数:
192