图论类型各题总结acm

上传人:公**** 文档编号:486229100 上传时间:2024-02-21 格式:DOC 页数:38 大小:100.04KB
返回 下载 相关 举报
图论类型各题总结acm_第1页
第1页 / 共38页
图论类型各题总结acm_第2页
第2页 / 共38页
图论类型各题总结acm_第3页
第3页 / 共38页
图论类型各题总结acm_第4页
第4页 / 共38页
图论类型各题总结acm_第5页
第5页 / 共38页
点击查看更多>>
资源描述

《图论类型各题总结acm》由会员分享,可在线阅读,更多相关《图论类型各题总结acm(38页珍藏版)》请在金锄头文库上搜索。

1、hdu4318 Power transmission 最短路 当数据很大的时候的解决办法 一道题目的解题全过程记录最短路 解决大数据模拟链表Power transmissionTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 663 Accepted Submission(s): 231Problem DescriptionThe project WestEast power transmission is famous around t

2、he world。 It transmits the electricity from western areas to east China. There are many nodes in the power system。 Each node is connected with several other nodes in the system by cable。 Power can be only transmitted between two connected nodes。 For each node, it cant send power to two or more other

3、 nodes at the same time。As we have all known, power will be loss during the transmission。 Bob is the chief engineer of the project。 He wants to build a transmission line which send power from one node to another node and minimize the power loss at the same time。 Now he asks you to help him solve the

4、 problem。 InputThere are several test cases. For each test case, the first line contains an integer N (0 N 50000) which represents the number of nodes in the power system。 Then there will be N groups of data following。 For the i-th(0 i N) group, the first line is an integer ki (ki 50), which means t

5、he node i is connected with ki nodes. The rest of the ith group data are divided into ki lines. Each line contains an integer ai (0 2 4, loss power is 100 50 + 100 * (100-50)20 = 60.00MicrosoftInternetExplorer402DocumentNotSpecified7。8Normal0题意:多个点 从一个点往另一个点运输天然气 但是从某点到另外一点是会有损耗的 题中输入的即为损耗的百分数 问从点s到

6、t最少损耗多少 分析: 很明显是最短路问题 但是有个比较卡人的地方 就是最多会有50000个点 数据太大 用map数组存不下 会爆掉 我们考虑到用链表 就用了数组去模拟链表 保存从当前点能到达的点队长把写解题报告的任务光荣的交给了我 但是我对看代码表示相当的纠结 所以就自己去写了个 好理解 把自己的贴上 /#includestdio。hincludestruct hahaint son55; /记录从当前点到其它能走到的点double son_val55; /记录从当前点到其它能走到的点的消耗int cnt;/记录存取的儿子个数a50100;int n,flag,s,t,M,used50100

7、;double min50100;double find_short()/模拟以前数据比较小的时候的模板 int i,j,pos,cnt; double mm; memset(used,0,sizeof(used); for(i=1;i=n;i+) mini=1; cnt=t; while(cnt) minas。soncnt=as。son_valcnt; useds=1; mins=0; for(i=2;i=n;i+) mm=1; for(j=1;j=n;j+) if(!usedjmmminj) pos=j; mm=minj; if(mm=1) flag=1;return 0; usedpos

8、=1; cnt=apos。cnt; for(j=0;jcnt;j+) if(!usedapos。sonj&minpos+(1。0-minpos)*apos.son_valjminapos.sonj) minapos。sonj=minpos+(1.0minpos)apos。son_valj; if(pos=t) return mint;/这里很重要 不加会超时的哦 return mint;int main()int i,m,x,y;double val,k;while(scanf(d,n)!=EOF)flag=0;for(i=1;i=n;i+) ai。cnt=0;for(i=1;i#includestring。hint n,used1005;double map10051005,min1005;void find_short(int s)int i,j,pos;double mm;me

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 工作计划

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号