#abc375g. G - Road Blocked 2

G - Road Blocked 2

Score : 575575 points

问题陈述

在AtCoder国家,有编号为11NNNN个城市,以及编号为11MMMM条道路。 第ii条道路双向连接城市AiA_iBiB_i,长度为CiC_i

对于每个i=1,,Mi = 1, \ldots, M,确定以下两个值是否不同。

  • 当所有道路都可通行时,从城市11到城市NN的最短距离
  • 当除了第ii条道路外其他M1M - 1条道路都可通行时,从城市11到城市NN的最短距离

如果城市NN在这两种情况中的一种可以被城市11到达,但在另一种情况中不能到达,则认为这两个值是不同的。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

In the nation of AtCoder, there are NN cities numbered 11 to NN, and MM roads numbered 11 to MM.
Road ii connects cities AiA_i and BiB_i bidirectionally and has a length of CiC_i.

For each i=1,,Mi = 1, \ldots, M, determine whether the following two values are different.

  • The shortest distance from city 11 to city NN when all roads are passable
  • The shortest distance from city 11 to city NN when the M1M - 1 roads other than road ii are passable

If city NN can be reached from city 11 in one of these cases but not the other, the two values are considered different.

Constraints

  • 2N2×1052 \leq N \leq 2 \times 10^5
  • 1M2×1051 \leq M \leq 2 \times 10^5
  • 1Ai<BiN1 \leq A_i < B_i \leq N
  • All pairs (Ai,Bi)(A_i, B_i) are distinct.
  • 1Ci1091 \leq C_i \leq 10^9
  • City NN can be reached from city 11 when all roads are passable.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN MM

A1A_1 B1B_1 C1C_1

\vdots

AMA_M BMB_M CMC_M

Output

Print MM lines. The ii-th line should contain Yes if the shortest distance from city 11 to city NN when all roads are passable is different from the shortest distance when the M1M - 1 roads other than road ii are passable, and No otherwise.

If city NN can be reached from city 11 in one of these cases but not the other, the two values are considered different.

Sample Input 1

3 3
1 2 5
1 3 10
2 3 6

Sample Output 1

No
Yes
No

When all roads are passable, the shortest distance from city 11 to city 33 is 1010.

  • When the two roads other than road 11 are passable, the shortest distance is 1010.
  • When the two roads other than road 22 are passable, the shortest distance is 1111.
  • When the two roads other than road 33 are passable, the shortest distance is 1010.

Sample Input 2

4 6
2 3 1
2 4 1
3 4 1
1 2 1
1 3 1
1 4 1

Sample Output 2

No
No
No
No
No
Yes

When all roads are passable, the shortest distance from city 11 to city 44 is 11.

When the five roads other than road 66 are passable, the shortest distance is 22.

Sample Input 3

2 1
1 2 1

Sample Output 3

Yes

When the zero roads other than road 11 are passable, city 22 cannot be reached from city 11.