Logo
(追記) (追記ここまで)

31354번 - Tri-color Spanning Tree 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB21151066.667%

문제

bobo has got an undirected graph $G,ドル whose edges are colored in red, green and blue.

He would like to count the number of spanning trees with at most $g$ green edges and $b$ blue edges modulo $(10^9 + 7)$.

입력

The first line contains 4ドル$ integers $n, m, g, b$. $n$ and $m$ denote the number of vertices and edges of $G,ドル respectively (1ドル \leq n \leq 40, 0 \leq m \leq 10^5, 0 \leq g, b < n$).

The vertices are conveniently numbered by 1,ドル 2, \dots, n$.

Each of the following $m$ lines contains 3ドル$ integers $a_i, b_i, c_i,ドル which denotes an edge between vertices $a_i$ and $b_i$ (1ドル \leq a_i, b_i \leq n, a_i \neq b_i, 1 \leq c_i \leq 3$). $c_i = 1, 2, 3$ denotes that the color of the $i$-th edge is red, green or blue, respectively.

출력

A single integer denotes the number of spanning trees.

제한

예제 입력 1

2 3 0 0
1 2 1
1 2 2
1 2 3

예제 출력 1

1

예제 입력 2

3 6 1 0
1 2 1
1 2 1
2 3 1
2 3 2
3 1 2
3 1 2

예제 출력 2

10

힌트

출처

Contest > Open Cup > 2014/2015 Season > Stage 10: Grand Prix of China I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /