高中纪中OJ3077. 【备战NOIP2012图论专项模拟试题】外星人入侵 题解
来源:互联网 发布:中登公司 网络投票 编辑:程序博客网 时间:2024/05/01 21:44
problem:
外星人入侵地球。可怕的吃人外星人正在全国各地依次序建立它们的基地。
全国共有N(1≤ N ≤10,000)座城市,城市编号1~N。城市之间有M(0≤ M ≤100,000)条双向道路相连。外星人计划建立A(0≤A≤N)个基地。
你只有在距离当前所有外星人基地至少K(1≤K≤100)单位长度的城市才能得到安全。
所以你必须赶快写一个程序决定走到哪里去。
input:
7 6 3 31 2 11 3 12 5 13 6 11 4 14 7 2214
output:210思路:进行a次spfa,不过dis和exist数组都不用清空,只用判断进行i次spfa后有哪几个dis[j]是不小于k的
伪代码: for l:=1 to n1 do begin que[1]:=a[l]; exist[a[l]]:=true; head:=0; tail:=1; dis[a[l]]:=0; while (head<>tail)do begin head:=head mod 200000+1; x:=que[head]; i:=last[x]; while (i<>0) do begin y:=tov[i]; if (dis[y]>dis[x]+len[i])then begin dis[y]:=dis[x]+len[i]; if (not exist[y])then begin tail:=tail mod 200000+1; que[tail]:=y; exist[y]:=true; end; end; i:=next[i]; end; exist[x]:=false; end; zx:=0; for j:=1 to n do begin if dis[j]>=k then inc(zx); end; writeln(zx); end;//spfa
0 0
- 高中纪中OJ3077. 【备战NOIP2012图论专项模拟试题】外星人入侵 题解
- 【备战NOIP2012图论专项模拟试题】外星人入侵
- 3077. 【备战NOIP2012图论专项模拟试题】外星人入侵 (Standard IO)
- 高中纪中OJ3078. 【备战NOIP2012图论专项模拟试题】无线通讯网
- 纪中3076【备战NOIP2012图论专项模拟试题】位图 题解
- 纪中高中OJ3079. 【备战NOIP2012图论专项模拟试题】砍树题解
- 【备战NOIP2012图论专项模拟试题】砍树 纪中3079 dfs
- jzoj 3076. 【备战NOIP2012图论专项模拟试题】位图
- 【备战NOIP2012图论专项模拟试题】位图
- 【备战NOIP2012图论专项模拟试题】无线通讯网
- 【备战NOIP2012图论专项模拟试题】砍树
- 【备战NOIP2012图论专项模拟试题】砍树
- 3076. 【备战NOIP2012图论专项模拟试题】位图 (Standard IO)
- 3078. 【备战NOIP2012图论专项模拟试题】无线通讯网 (Standard IO)
- 3079. 【备战NOIP2012图论专项模拟试题】砍树 (Standard IO)
- 【图论最短路】【CQBZOJ 1634】【图论专项赛】外星人入侵
- 外星人入侵_纪中3077_spfa
- 高中OJ3056【NOIP2012模拟10.27】数字
- 2047. 对布满灰尘的西洋棋宣告将军
- 【NOIP提高】Binary
- poj1200 hash入门
- Android图片加载框架
- LightOJ 1080
- 高中纪中OJ3077. 【备战NOIP2012图论专项模拟试题】外星人入侵 题解
- 验证验证码
- ACdream 1020The Game about KILL
- Android中使用百度APIstore接口
- 容斥原理 2016.8.20
- Trie Tree简单实现
- 用extern定义全局变量
- UVA | Optimal Binary Search Tree
- https 和 http 端口号是多少