{"problem":{"name":"Ex - Constrained Tree Degree","description":{"content":"You are given an integer $N$ and a set $S=\\lbrace S_1,S_2,\\ldots,S_K\\rbrace$ consisting of integers between $1$ and $N-1$. Find the number, modulo $998244353$, of trees $T$ with $N$ vertices numbered ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":5000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc303_h"},"statements":[{"statement_type":"Markdown","content":"You are given an integer $N$ and a set $S=\\lbrace S_1,S_2,\\ldots,S_K\\rbrace$ consisting of integers between $1$ and $N-1$.\nFind the number, modulo $998244353$, of trees $T$ with $N$ vertices numbered $1$ through $N$ such that:\n\n*   $d_i\\in S$ for all $i\\ (1\\leq i \\leq N)$, where $d_i$ is the degree of vertex $i$ in $T$.\n\n## Constraints\n\n*   $2\\leq N \\leq 2\\times 10^5$\n*   $1\\leq K \\leq N-1$\n*   $1\\leq S_1 < S_2 < \\ldots < S_K \\leq N-1$\n*   All values in the input are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $K$\n$S_1$ $\\ldots$ $S_K$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc303_h","tags":[],"sample_group":[["4 2\n1 3","4\n\nA tree satisfies the condition if the degree of one vertex is $3$ and the others' are $1$. Thus, the answer is $4$."],["10 5\n1 2 3 5 6","68521950"],["100 5\n1 2 3 14 15","888770956\n\nPrint the count modulo $998244353$."]],"created_at":"2026-03-03 11:01:13"}}