No.2507 Yet Another Subgraph Counting
タグ : / 解いたユーザー数 15
作問者 :
emthrm
torisasami4
rniya
Problem Statement
There is a simple undirected graph with $n$ vertices and $m$ edges, whose vertices are numbered $1,2,\ldots,n$ and whose edges are numbered $1,2,\ldots,m$. Edge $i$ connects vertex $u _ i$ and vertex $v _ i$ bidirectionally.
suisen paints $0$ or more of the $m$ edges red and the remaining edges blue. In the following, a simple cycle consisting only of red edges is simply called a red cycle.
Find the number of ways suisen can paint the edges such that the following condition is satisfied.
- For any $2$ distinct red cycles, no vertex is contained in both of them.
Here, for $2$ red cycles, the $2$ red cycles are considered different if and only if there exists an edge contained in only one of them.
It can be proved that the answer is less than $2^{63}$ under the constraints of this problem.
Input
The input is given from standard input in the following format.
$n\ m$ $u _ 1\ v _ 1$ $u _ 2\ v _ 2$ $\vdots$ $u _ m\ v _ m$
- All input values are integers.
- The given graph is simple.
- $2\leq n\leq 13$
- $1\leq m\leq \dfrac{n(n - 1)}{2}$
- $1\leq u _ i \lt v _ i \leq n$
- If $i \neq j$, then $(u _ i, v _ i) \neq (u _ j, v _ j)$
Output
Print the answer on $1$ line, followed by a newline.
Sample
Sample 1
Input
6 7 1 4 1 5 2 5 3 5 3 6 4 5 5 6
Output
126
This input represents the following graph.
For example, if edges $1,2,3,4,6,7$ are painted red and edge $5$ is painted blue, the result is as shown in the following figure. In this case, the only red cycle is the one consisting of edges $1,2,6$. Therefore, this way of painting satisfies the condition.
As another example, if edges $1,2,4,5,6,7$ are painted red and edge $3$ is painted blue, the result is as shown in the following figure. In this case, there are $2$ red cycles: the one consisting of edges $1,2,6$ and the one consisting of edges $4,5,7$. Since these $2$ cycles both contain vertex $5$, this way of painting does not satisfy the condition.
There are $2 ^ m = 128$ ways to paint the edges in total, and only the following $2$ ways do not satisfy the condition.
- Edges $1,2,4,5,6,7$ are painted red and edge $3$ is painted blue
- All edges are painted red
Therefore, the answer for this input is $128 - 2 = 126$.
Sample 2
Input
6 10 1 2 1 3 1 4 1 5 2 3 2 4 2 6 3 5 4 6 5 6
Output
816
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。