Reading books /// Prim+BFS oj21633】的更多相关文章

题目大意: 输入 N,M 接下来1-N行输入读该书的用时time[i] 接下来1-M行输入a,b  表示a和b是similar的 若a读过则读b用时为 time[b]/2 ,若b读过则读a用时为 time[a]/2 Sample Input 2 16100 13 21230 11 23 12460 10 0 Sample Output 11310 Hint For the first test case, if LRJ read the books in the order (0, 1), th…
Problem B Reading books (Input File: book.in / Standard Output) In the summer vacation, LRJ wants to improve himself in computer science. So he finds out N books of computer science in the school library. The books are numbered from 0 to N-1. To fini…
( ̄▽ ̄)" #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<vector> #include<queue> using namespace std; const int INF=10e8; ; int col,row,k,minn; char str[MAXN][MAXN]; ][MAXN*],lowdis…
题目链接:http://poj.org/problem?id=3026 题目大意:在一个y行 x列的迷宫中,有可行走的通路空格’  ‘,不可行走的墙’#’,还有两种英文字母A和S,现在从S出发,要求用最短的路径L连接所有字母,输出这条路径L的总长度. 解题思路:相当于所有的字母A和S都是结点,求连接这些结点的最小距离和,是最小生成树的题目.先用BFS求各点间的距离,然后再用Prim(Kruskal也可以)求出最小距离就可以了. 注意:输完行列m和n之后,后面有一堆空格,要用gets()去掉,题目…
Borg Maze Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12729   Accepted: 4153 Description 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 desc…
题意:有\(n\)本书,A和B都至少要从喜欢的书里面读\(k\)本书,如果一本书两人都喜欢的话,那么他们就可以一起读来节省时间,问最少多长时间两人都能够读完\(k\)本书. 题解:我们可以分\(3\)种情况来存,即: ​ 1.\(a=b=1\). 2.\(a=1,b=0\). 3.\(a=0,b=1\). 对于2和3来说,我们可以将他们排序,然后合并到一起,最后放到第1种情况中再排一次序,取前\(k\)个前缀和即可. 代码: int n,k; int t,x,y; int ans; vector…
普里姆算法(Prim算法),图论中的一种算法,可在加权连通图里搜索最小生成树.意即由此算法搜索到的边子集所构成的树中,不但包括了连通图里的所有顶点,且其所有边的权值之和亦为最小.该算法于1930年由捷克数学家沃伊捷赫·亚尔尼克发现:并在1957年由美国计算机科学家罗伯特·普里姆独立发现:1959年,艾兹格·迪科斯彻再次发现了该算法.因此,在某些场合,普里姆算法又被称为DJP算法.亚尔尼克算法或普里姆-亚尔尼克算法 算法过程图解:遍历点,用贪心法选择与集合内的点相连的点的最小值: 模板: #inc…
For much of the last year, intellectuals and officials in China -- land of world-beating students and, in a bygone age, the scholar official -- have been wringing their hands over the country's declining interest in reading. bygone:过去的        wringin…
描述 Jim is fond of reading books, and he has so many books that sometimes it's hard for him to manage them. So he is asking for your help to solve this problem. Only interest in the name, press year and price of the book, Jim wants to get a sorted lis…
List the Books Time Limit: 2 Seconds      Memory Limit: 65536 KB Jim is fond of reading books, and he has so many books that sometimes it's hard for him to manage them. So he is asking for your help to solve this problem. Only interest in the name, p…