report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Minimum spanning tree 3 - FlandreOJ: Flandre Online Judge

Minimum spanning tree 3

Time limit: 1000 ms
Memory limit: 256 MB
For a graph with $n$ vertices and $m$ edges, count the number of distinct minimum spanning trees in this graph. Two spanning trees are considered different if there exists an edge in one tree that does not exist in the other. ### Input - The first line consists of two integers $n, m$. - The next $m$ lines, each containing three integers $u, v, w$ representing an edge of weight $w$ between $u$ and $v$. ### Output - Print the number of distinct minimum spanning trees modulo $31011$. ### Constraints - $1 \le n \le 100$. - $1 \le m \le 1000$. - $1 \le u, v \le n$. - $1 \le w \le 10^9$. - The number of edges having the same weight does not exceed $10$. ### Sample test Input ``` 4 6 1 2 1 1 3 1 1 4 1 2 3 2 2 4 1 3 4 1 ``` Output: ``` 8 ```
Disjoint Set Union (DSU)
DSU
Component sum
Minimum spanning tree
Parking
Remove edge
Yet another problem
Assignment query on tree
Watering
Minimum spanning tree 2
Fatal meal
Statement
All pairs
Query on tree
Minimum spanning tree 3
Topic
DSU
Rating 1900
Source JSOI
Solution (0) Solution