#abc235h. Ex - Painting Weighted Graph
Ex - Painting Weighted Graph
Score : points
问题描述
给定一个含 个顶点和 条边的无向图。第 条边连接顶点 和 ,且具有权重 。
初始时,所有顶点都被涂成黑色。你可以最多进行 次以下操作:
- 操作:选择任意顶点 和任意整数 。将从顶点 出发,通过权重不大于 的边可达的所有顶点(包括 本身)涂成红色。
在完成操作后,有多少种可能的红色顶点集合?
请计算结果对 取模后的数量。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Given is an undirected graph with vertices and edges. The -th edge connects Vertices and and has a weight of .
Initially, all vertices are painted black. You can do the following operation at most times.
- Operation: choose any vertex and any integer . Paint red all vertices reachable from the vertex by traversing edges whose weights are at most , including itself.
How many sets can be the set of vertices painted red after the operations?
Find the count modulo .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3 2 1
1 2 1
2 3 2
Sample Output 1
6
For example, an operation with paints Vertices red, and an operation with paints Vertex .
After at most one operation, the set of vertices painted red can be one of the following six: .
Sample Input 2
5 0 2
Sample Output 2
16
The given graph may not be connected.
Sample Input 3
6 8 2
1 2 1
2 3 2
3 4 3
4 5 1
5 6 2
6 1 3
1 2 10
1 1 100
Sample Output 3
40
The given graph may have multi-edges and self-loops.
update @ 2024/3/10 10:13:01