Complement Spanning Trees

All submissions for this problem are available.
### Read problem statements in [Hindi](http://www.codechef.com/download/translated/AUG19/hindi/CSTREE.pdf), [Bengali](http://www.codechef.com/download/translated/AUG19/bengali/CSTREE.pdf), [Mandarin Chinese](http://www.codechef.com/download/translated/AUG19/mandarin/CSTREE.pdf), [Russian](http://www.codechef.com/download/translated/AUG19/russian/CSTREE.pdf), and [Vietnamese](http://www.codechef.com/download/translated/AUG19/vietnamese/CSTREE.pdf) as well. You are given a small graph $G_s$ with $N$ nodes (numbered $1$ through $N$) and $M$ edges. Let's create a big graph $G_b$ with $NK$ nodes (numbered $1$ through $NK$) and $MK$ edges. $G_b$ consists of $K$ copies of $G_s$ ― formally, for each $k$ ($0 \le k \le K1$) and each edge between nodes $u$ and $v$ in $G_s$, there is an edge between nodes $u+kN$ and $v+kN$ in $G_b$. Afterwards, let's take the complement of $G_b$ and call it $H$ ― formally, $H$ is a graph with $NK$ nodes (numbered $1$ through $NK$) such that for each pair of nodes, there is an edge between these two nodes in $H$ if and only if there is no edge between these two nodes in $G_b$. Count the number of spanning trees in $H$. Since this number could be very large, compute it modulo $998,244,353$. ### Input  The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.  The first line of each test case contains three spaceseparated integers $N$, $M$ and $K$.  Each of the next $M$ lines contains two spaceseparated integers $a$ and $b$ denoting that the nodes $a$ and $b$ in $G_s$ are connected by an edge. ### Output For each test case, print a single line containing one integer ― the number of spanning trees in $H$ modulo $998,244,353$. ### Constraints  $1 \le T \le 20$  $1 \le N \le 30$  $0 \le M \le N(N1)/2$  $1 \le K \le 10^8$  $1 \le a, b \le N$  $G_s$ does not contain any selfloops or multiedges ### Subtasks **Subtask #1 (15 points):** $K \le 10$ **Subtask #2 (19 points):**  $K \le 50$  $M \le 5$ **Subtask #3 (21 points):**  $K \le 5,000$  $M = N(N1)/2$ **Subtask #4 (22 points):** $K \le 5,000$ **Subtask #5 (23 points):** original constraints ### Example Input ``` 5 3 0 1 3 3 2 1 2 1 3 2 3 3 3 1 1 2 1 3 2 3 6 9 20 1 3 2 3 4 3 5 3 6 3 1 4 2 4 4 5 4 6 30 4 5000 1 2 3 4 5 6 6 7 ``` ### Example Output ``` 3 81 0 13872131 797280964 ``` ### Explanation **Example case 1:** $H$ is the complete graph on three nodes, so the number of spanning trees is $3$ (any two of the edges form a spanning tree).Author:  lg5293 
Editorial  https://discuss.codechef.com/problems/CSTREE 
Tags  algebra, aug19, fft, hard, interpolation, kirchoffstheorem, lg5293, polynomial, vijju123 
Date Added:  24062019 
Time Limit:  3 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions