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

33114번 - Count DFS Tree 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB552100.000%

문제

You are currently studying a tree traversal algorithm called the Depth First Search (DFS). Suppose you have a rooted tree of $n$ nodes (numbered from 1ドル$ to $n$) with a depth of $K$ (numbered from 1ドル$ to $K$). The root (the node at depth 1ドル$) is located at node 1ドル$. All leaves are located at the same depth, that is, at depth $K$. Node $i$ has an array of children nodes $c_i,ドル which could be empty if $i$ is a leaf node. The pseudocode of the algorithm is presented as follows.

DFS(u, depth):
 let res be an empty array
 append depth to res
 for each v in c[u]:
 let D be an array initialized with DFS(v, depth + 1)
 for each x in D:
 append x to res
return res

Consider the trees in the following illustration. The return values of DFS(1, 1) for the tree on the left and the tree on the right are $[1, 2, 3, 3, 3]$ and $[1, 2, 3, 2, 3],ドル respectively.

Denote $f_K(n)$ as the number of distinct return values of DFS(1, 1) across all trees consisting of $n$ nodes and all leaves are located in depth $K$. You are given $M$ integers: $A_1, A_2, \dots , A_M$. Determine the value of $f_K(A_1) \times f_K(A_2) \times \cdots \times f_K(A_M)$. As the answer can be very large, find the answer modulo 998ドル,円 244,円 353$.

입력

The first line consists of two integers $K$ $M$ (1ドル ≤ K, M ≤ 100,円 000$).

The following line consists of $M$ integers $A_i$ ($K ≤ A_i ≤ 200,円 000$).

출력

Output a single integer representing the value of $f_K(A_1) \times f_K(A_2) \times \cdots \times f_K(A_M)$ modulo 998ドル,円 244,円 353$.

제한

예제 입력 1

3 2
5 6

예제 출력 1

6

The value of $f_3(5)$ and $f_3(6)$ are 2ドル$ and 3ドル,ドル respectively. The illustration on the description shows the trees of 5ドル$ nodes that give distinct return values of DFS(1, 1). The following illustration is for the trees of 6ドル$ nodes.

예제 입력 2

100000 1
200000

예제 출력 2

269130693

힌트

출처

ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2024 I번

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

출처

대학교 대회

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

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