leetcode-daily/cpp/2205/220514.cpp

109 lines
5.3 KiB
C++

#include <vector>
#include <tuple>
#include <queue>
#include <iostream>
/**
* 743. Network Delay Time
* You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui, vi, wi), where ui is the source node, vi is the target node, and wi is the time it takes for a signal to travel from source to target.
* We will send a signal from a given node k. Return the time it takes for all the n nodes to receive the signal. If it is impossible for all the n nodes to receive the signal, return -1.
*
* Comment: This is Dijkstra's algorithm.
*/
#define 类 class
#define 公共的 public
#define 静态 static
#define 整数 int
#define 标准 std
#define 常量 const
#define 为了 for
#define 规模 size
#define 向量 vector
#define 保留 reserve
#define 当 while
#define 自动 auto
#define 顶部 top
#define 如果 if
#define 继续 continue
#define 主函数 main
#define 真 true
#define 返回 return
#define 开始 begin
#define 结束 end
#define 更大的 greater
#define 最大元素 max_element
#define 推 push
#define 最后原地构造 emplace_back
#define 元组 tuple
#define 空 empty
#define 优先队列 priority_queue
#define 组合 pair
#define 真假 bool
#define 弹出 pop
#define 输出 cout
#define 推到末尾 push_back
#define 左中括号 [
#define 右中括号 ]
#define 左括号 (
#define 右括号 )
#define 等于 =
#define 相等 ==
#define 小于等于 <=
#define 加 +
#define 加加 ++
#define 减减 --
#define 减 -
#define 小于 <
#define 大于 >
#define 左大括号 {
#define 右大括号 }
#define 分号 ;
#define 逗号 ,
Solution
:
networkDelayTime :: :: &
.
:: ::
:: ::
.
0
. 0 1 1 1 2
0 1 .
:: 0x6FFFFFFF
:: 访
:: :: :: :: ::
. 0
0
!.
.
.
访
访
:
.
*:: . .
0x6FFFFFFF ? 1 :
:: << Solution::networkDelayTime 2 1 1 2 3 1 3 4 1 4 2
0