|
||||||||||
Jumping on a CactusTime Limit: 2000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 77 Accepted Submission(s): 31 Problem Description It is preferrable to read the pdf statment. Cuber QQ has recently learned jumping on graphs. He now wants to demonstrate his skills on a cactus. Recall that, cactus refers to a graph with every edge appearing in at most one cycle. If you do not know what a cycle is, formally, a cycle of length $k$ denotes an edge sequence $(u_1,u_2), (u_2,u_3),\ldots,(u_{k-1},u_k),(u_k,u_1)$. Assuming you are given an undirected cactus $G=(V, E)$, with $n$ vertices and $m$ edges. A jumping on the cactus can be thought of as a visit to all vertices where every vertex is visited exactly once. That can be represented with a permutation of $1$ to $n$, $p_1, p_2, \ldots, p_n$, and they are visited in order. Cuber QQ also wishes his jumping to be gradually approaching or distancing away from a particular node $e$. Concretely, we define $d(a, b)$ to be the distance from $a$ to $b$ (the minimum edges needs to be passed through from $a$ to $b$). A jumping is defined to be monotonic if,
Count the number of different monotonic jumping plans. Since the answer can be very large, you should print the answer modulo $998~244~353$. Input The first line of the input contains a single integer $T$ ($1\le T\le 30$), denoting the number of test cases. For each of the next $T$ cases:
There are at most $10$ test cases where $n\ge 1~000$. Output For each test case, output one line contains one integer denoting the answer modulo $998~244~353$. NotesFor the example, $G$ looks like: $3$ is the index of reference vertex. There are $8$ correct permutations:
Sample Input
Sample Output
Source | ||||||||||
|