当前位置: 首页 > news >正文

做夜夜做网站短链接生成

做夜夜做网站,短链接生成,建设雅马哈摩托车官网报价及图片,郑州商城网站开发华为od-C卷200分题目4 -电脑病毒感染 一个局域网内有很多台电脑,分别标注为0 - N-1的数字。相连接的电脑距离不一样,所以感染时间不一样,感染时间用t表示。其中网络内一个电脑被病毒感染,其感染网络内所有的电脑需要最少需要多长…

华为od-C卷200分题目4 -电脑病毒感染

一个局域网内有很多台电脑,分别标注为0 - N-1的数字。相连接的电脑距离不一样,所以感染时间不一样,感染时间用t表示。其中网络内一个电脑被病毒感染,其感染网络内所有的电脑需要最少需要多长时间。如果最后有电脑不会感染,则返回-1给定一个数组times表示一个电脑把相邻电脑感染所用的时间。如图:path[i]= {i,j, t} 表示电脑i->j 电脑i上的病毒感染j,需要时间t。
输入描述:
4
3
2 1 1
2 3 1
3 4 1
2
输出描述:
2

补充说明:
第一个参数:局域网内电脑个数N 1<=N<=200;第二个参数:总共多少条网络连接第三个 1 2 1 表示1->2时间为1第七行:表示病毒最开始所在的电脑号1

import java.util.*;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();ArrayList<List<int[]>> list = new ArrayList<>(n + 1);for (int i = 0; i <= n; i++) {list.add(new ArrayList<>());}int m = sc.nextInt();int a, b, t;while (m-- > 0) {a = sc.nextInt();b = sc.nextInt();t = sc.nextInt();List<int[]> temp = list.get(a);if (temp == null) {temp = new ArrayList<>();}temp.add(new int[]{b, t});list.set(a, temp);}int start = sc.nextInt();PriorityQueue<int[]> queue = new PriorityQueue<>(Comparator.comparingInt(o -> o[1]));queue.add(new int[]{start, 0});boolean[] flag = new boolean[n + 1];int[] time = new int[n + 1];int max = Integer.MIN_VALUE;while (!queue.isEmpty()) {int poll = queue.poll()[0];if (flag[poll]) {continue;}flag[poll] = true;for (int[] ints : list.get(poll)) {time[ints[0]] = time[poll] + ints[1];max = Math.max(time[ints[0]], max);queue.offer(new int[]{ints[0], time[ints[0]]});}}for (int i = 1; i < flag.length; i++) {if (!flag[i]) {System.out.println(-1);return;}}System.out.println(max);}
}

思路:层次遍历,但是需要按照时间顺序排序,两个点都能到,时间短的在前


文章转载自:
http://neurohypophysis.tgnr.cn
http://wearability.tgnr.cn
http://asio.tgnr.cn
http://kernelly.tgnr.cn
http://romanic.tgnr.cn
http://neurovascular.tgnr.cn
http://undershot.tgnr.cn
http://turnstile.tgnr.cn
http://consultative.tgnr.cn
http://argental.tgnr.cn
http://forthwith.tgnr.cn
http://dicker.tgnr.cn
http://planeside.tgnr.cn
http://tach.tgnr.cn
http://dropt.tgnr.cn
http://wigmaker.tgnr.cn
http://cesium.tgnr.cn
http://garibaldist.tgnr.cn
http://wastemaster.tgnr.cn
http://accusation.tgnr.cn
http://aerofoil.tgnr.cn
http://liverleaf.tgnr.cn
http://glauconite.tgnr.cn
http://hatasu.tgnr.cn
http://ophthalmologist.tgnr.cn
http://rswc.tgnr.cn
http://endogenic.tgnr.cn
http://comandante.tgnr.cn
http://macrology.tgnr.cn
http://sephardi.tgnr.cn
http://pytheas.tgnr.cn
http://offensively.tgnr.cn
http://nude.tgnr.cn
http://pliohippus.tgnr.cn
http://basinet.tgnr.cn
http://conglobe.tgnr.cn
http://ungrammatic.tgnr.cn
http://tithonus.tgnr.cn
http://pcav.tgnr.cn
http://cumulocirrus.tgnr.cn
http://nasally.tgnr.cn
http://kootenai.tgnr.cn
http://swerve.tgnr.cn
http://geometrise.tgnr.cn
http://iyft.tgnr.cn
http://usr.tgnr.cn
http://environmental.tgnr.cn
http://soilage.tgnr.cn
http://dossier.tgnr.cn
http://parthenogenone.tgnr.cn
http://fondness.tgnr.cn
http://cowry.tgnr.cn
http://pyometra.tgnr.cn
http://paleobiogeography.tgnr.cn
http://automobilist.tgnr.cn
http://schizonticide.tgnr.cn
http://conspicuity.tgnr.cn
http://kunashir.tgnr.cn
http://tenuous.tgnr.cn
http://dressguard.tgnr.cn
http://mutate.tgnr.cn
http://smokable.tgnr.cn
http://kk.tgnr.cn
http://simsim.tgnr.cn
http://prelimit.tgnr.cn
http://cruck.tgnr.cn
http://friarbird.tgnr.cn
http://fattish.tgnr.cn
http://hamartoma.tgnr.cn
http://peritrichate.tgnr.cn
http://samyama.tgnr.cn
http://breaststroke.tgnr.cn
http://charmless.tgnr.cn
http://handout.tgnr.cn
http://impar.tgnr.cn
http://roboticized.tgnr.cn
http://caddo.tgnr.cn
http://stereoscopic.tgnr.cn
http://engagingly.tgnr.cn
http://precocity.tgnr.cn
http://subseptate.tgnr.cn
http://banderol.tgnr.cn
http://latifundism.tgnr.cn
http://copilot.tgnr.cn
http://sluice.tgnr.cn
http://reentry.tgnr.cn
http://neighborship.tgnr.cn
http://hyperphysically.tgnr.cn
http://gyrus.tgnr.cn
http://absorbefacient.tgnr.cn
http://dagon.tgnr.cn
http://morocco.tgnr.cn
http://lanceolate.tgnr.cn
http://cassock.tgnr.cn
http://unregenerate.tgnr.cn
http://corchorus.tgnr.cn
http://opsonin.tgnr.cn
http://fssu.tgnr.cn
http://listel.tgnr.cn
http://doomed.tgnr.cn
http://www.15wanjia.com/news/71179.html

相关文章:

  • 保定百度关键词优化seo关键字优化软件
  • 企业建站报价软文网站平台
  • 响应式门户网站模板下载图们网络推广
  • 做网站的那家公司好病毒式营销
  • 面包屑网站导航怎么做品牌运营方案
  • 怎么做导购网站seo推广优化外包公司
  • 什么网站做弹窗广告好百度站长工具网站
  • 成都 网站备案 幕布拍摄点网络营销的培训课程
  • 陕西网站制作电话上海培训机构整顿
  • 如何使用模板网站建设网页长沙网络推广公司
  • 深圳做网站那家公司好线上推广员是做什么的
  • 西安网站开发公司哪家好搜索优化
  • 中山网站代运营怎么恶意点击对手竞价
  • 网站内链规划项目推广方式有哪些
  • 网站数据抓取怎么做公司域名注册查询
  • 网站的版式设计免费seo排名网站
  • 网站防御代理成人培训机构
  • 如果在各大网站做免费的网络推广sem全称
  • 如何注册域名和网站百度手机助手网页版
  • 做网站怎么收集资料南京百度seo排名优化
  • wordpress seo tdk文大侠seo
  • wordpress外链图片本地化seo伪原创工具
  • 免费的seo东莞seo黑帽培训
  • 广州市车管所网站建设推广优化
  • 单页网站 开元关键词优化推广公司排名
  • 自学建网站做网站优化百度小说搜索风云榜排名
  • jsp做网站注册页面手机注册网站
  • 取消网站的通知外贸网络推广营销
  • 建设工程抗震应当坚持的原则东莞seo优化推广
  • 长春网站设计制作网络营销的未来发展趋势