POJ 1511 【heap+dij】】的更多相关文章

题意: t组样例. 每组有n个节点,有m条单向边. 有m组输入,每组a b c 表示从a到b的单向边的权值是c. 求解,从编号为1的节点出发,有n-1个人,要求他们分别到达编号从2到n的节点再返回,所有边的权值的和最小是多少. 思路: 构图,构两个图,分别是正向图和反向图,然后用dij算单源最短路,将所有点到1的最短路加起来就是答案. 这题注意 1.inf原先的99999999定义不够大. 2.需要用到优先队列优化. 3.vector会超时,需要写手工邻接表. 4.一开始看到网上有人写getin…
poj 3225 这题是用线段树解决区间问题,看了两天多,算是理解一点了. Description LogLoader, Inc. is a company specialized in providing products for analyzing logs. While Ikki is working on graduation design, he is also engaged in an internship at LogLoader. Among his tasks, one is…
Problem DescriptionIn the second year of the university somebody started a study on the romantic relations between the students. The relation "romantically involved" is defined between one girl and one boy. For the study reasons it is necessary…
分析:正向加边,反向加边,然后两遍dij #include<cstdio> #include<cstring> #include<queue> #include<cstdlib> #include<algorithm> #include<vector> #include<cmath> using namespace std; typedef long long LL; ; const int INF=0x3f3f3f3f;…
题意: 给出n个工厂的产品参数带宽b和价格p,在这n个工厂里分别选1件产品共n件,使B/P最小,其中B表示n件产品中最小的b值,P表示n件产品p值的和. 输入 iCase n 表示iCase个样例n个工厂 m1 p1 b1 p2 b2..pm1 bm1 //第一个工厂有m1个同种类不同参数的产品,每一个产品的参数分别是p1 b1 p2 b2 m2 p1 b1 p2 b2..pm2 bm2 ... mn p1 b1 p2 b2..pmn bmn 思路: 排序,先把b从小到大排序,然后把p从小到大排…
http://poj.org/problem?id=2031 Description You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task.  The space stati…
题目传送门//res tp poj 题意 给出一棵有权树,求一个节点集的权值和,满足集合内的任意两点不存在边 分析 每个点有选中与不选中两种状态,对于第\(i\)个点,记选中为\(sel_i\),不选中为\(insel_i\) 若某一节点选中,则其子节点都不能选中. 若某一节点不选中,则其子节点有两种选择:1.选中 2.不选中 故 \[sel_i = val_i +\sum_j insel_j\] \[insel_i = \sum_j max\{insel_j,sel_j\}\] 其中\(j\)…
poj 3280 题意:给定一个字符串和每个字符删去和增加的代价,求使字符串变成回文串操作所需的最小代价. 题解:哇!开心!终于亲自做对了!做完这两题这个就回了.uva10739  uva 10453 #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; struct st{ int ad,de; }; st a[]; ][…
首先考虑下面的问题:Code[VS] 3657 我们用以下规则定义一个合法的括号序列: (1)空序列是合法的 (2)假如S是一个合法的序列,则 (S) 和[S]都是合法的 (3)假如A 和 B 都是合法的,那么AB和BA也是合法的 例如以下是合法的括号序列: (), [], (()), ([]), ()[], ()[()] 以下是不合法括号序列的: (, [, ], )(, ([]), ([() 现在给定一些由'(', ')', '[', ,']'构成的序列 ,请添加尽量少的括号,得到一个合法的…
The area Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6524    Accepted Submission(s): 4578题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1071 Problem Description Ignatius bought a land last w…