传统题 1000ms 256MiB

Drahc Designs the Map

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

After graduation, Drahc joined YiHoMo and became a game designer. He has finished an outline of a map for his new game. There are several places on his map.

However, his boss, Teafrogsf, has proposed several suggestions that require Drahc to modify the map. After days and nights of revisions, Drahc fainted. But there still exists a last requirement for the map. You decide to assist him.

For convenience, we use a positive weighted undirected graph G=(V,E)G=(V,E) to represent the map. This requirement requires that for all spanning subgraphs of GG, there exists a unique spanning subgraph that has a minimum sum of weight. In other words, !G=(V,E)\exists !G' = (V,E') s.t. eGw(e)\sum_{e\in G'}w(e) minimizes (EEE'\subset E).

Drahc's map is under protection, so you can only modify one edge eEe\in E at one time with its weight increased by 11. Drahc wants his map to be modified as little as possible. Therefore, you need to modify as few times as possible, and since the modification method may not be unique, you only need to output the minimum number of modifications.

Format

Input

The first line of input contains 22 integers: n,m(1n105,1m2×105)n,m\,(1\leq n\leq 10^5, 1\leq m\leq 2\times10^5). nn represents the number of vertices in GG and mm represents the number of edges in GG.

The next mm lines, each containing 33 integers each: ui,viu_i,v_i and wi(1ui,vin,1wi109)w_i\,(1\leq u_i,v_i\leq n, 1\leq w_i\leq 10^9). It means there exists an edge between uiu_i and viv_i which is weighted wiw_i.

Output

One integer: the minimum number of modifications.

Samples

6 8
1 2 1
1 3 1
2 3 1
4 5 1
4 6 1
5 6 2
1 4 2
3 5 2
2

Hello ACM 2025

未参加
状态
已结束
规则
ACM/ICPC
题目
11
开始于
2025-8-14 13:00
结束于
2025-8-14 18:00
持续时间
5 小时
主持人
参赛人数
46