POJ 3026(BFS+prim)】的更多相关文章

http://poj.org/problem?id=3026 题意:任意两个字母可以连线,求把所有字母串联起来和最小. 很明显这就是一个最小生成树,不过这个题有毒.他的输入有问题.在输入m和N后面,可能有一大串的空格.就因为这个,我RE都有点懵了,要不是discuss里面有人说输入有问题,我都没注意到这个,原本只用了一个getchar吃掉最后的换行符.没想到之后还有空格.有点小坑. 思路:这个题目如果他给你一个图,那就是最裸的prim了.不过这个题的难点也就是在他给的图你不能用Prim,你只能通…
在一个迷宫里面需要把一些字母.也就是 ‘A’ 和 ‘B’连接起来,求出来最短的连接方式需要多长,也就是最小生成树,地图需要预处理一下,用BFS先求出来两点间的最短距离, ********************************************************************************** #include<algorithm> #include<stdio.h> #include<; ][] = { {,},{,},{-,},{,…
Meteor Shower Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 26455   Accepted: 6856 Description Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they h…
http://poj.org/problem?id=3026 Borg Maze Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12086   Accepted: 3953 Description The Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg coll…
The Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used to describe the group consciousness of the Borg civilization. Each Borg individual is linked to the collective by…
The Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used to describe the group consciousness of the Borg civilization. Each Borg individual is linked to the collective by…
思路:宽度优先搜索(BFS算法) #include<iostream> #include<stdio.h> #include<cmath> #include<cstring> using namespace std; int a,b; struct node{ int num; int step; }; node que[10000];//默认初始化为0 int visit[10000];//默认初始化为0 int prime(int d){ if(d<…
Cleaning Robot (bfs+dfs) Here, we want to solve path planning for a mobile robot cleaning a rectangular room floor with furniture. Consider the room floor paved with square tiles whose size fits the cleaning robot (1 * 1). There are 'clean tiles' and…
Description Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her safety, she vows to find her way to a safe location (one that is never destroy…
After going through the receipts from your car trip through Europe this summer, you realised that the gas prices varied between the cities you visited. Maybe you could have saved some money if you were a bit more clever about where you filled your fu…