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

21115번 - Colorful Components 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB98888.889%

문제

There are $n$ nodes, the $i$-th of which has color $c_i$. For a given integer $k$ (1ドル \le k \le n$), please count the number of ways to build exactly $n - 1$ undirected edges between the nodes, such that:

  1. The $n$ nodes form a connected graph.
  2. If we destroy every edge that connects two nodes of different colors, then every connected component in the remaining graph has at most $k$ vertices.

Two ways of building edges are considered different if and only if there exist two nodes $i$ and $j$ such that 1ドル \le i < j \le n$ and there is an edge between them in one of the two ways but not in the other.

Since the number could be large, you only need to output the answer modulo 10ドル^9 + 7$.

입력

The first line contains two integers, $n$ and $k$ (1ドル \le k \le n \le 300$).

The following $n$ lines contain integers $c_1, c_2, \ldots, c_n$ denoting the colors of the nodes, one integer per line (1ドル \le c_i \le n$).

출력

Output the answer modulo 10ドル^9 + 7$.

제한

예제 입력 1

5 3
1
1
3
1
5

예제 출력 1

125

예제 입력 2

4 2
2
1
1
1

예제 출력 2

7

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2021 > Day 7: North American Contest 1 K번

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

출처

대학교 대회

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

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