308747: CF1569F. Palindromic Hamiltonian Path

Memory Limit:256 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Palindromic Hamiltonian Path

题意翻译

给你一个有 $n$ 个顶点的简单无向图(即无重边自环),$n$ 是偶数。你要在每个顶点上写一个字符。每个字符都应该是小写拉丁字母表中的头 $k$ 之一。 对于图上的一条路径,如果恰好访问每个顶点一次,则称其为哈密顿路径。对于一个字符串,如果从左到右和从右到左读是一样的,则称其为回文串。对于一条哈密顿路径,如果按照路径的顺序将顶点上的字符连成一个字符串,这个字符串是一个回文串,则称其为回文哈密顿路径。 对于一个长度为 $n$ 的字符串,若满足以下条件,则称其是”好的“: - 字符串中的每个字符都是小写拉丁字母表中的头 $k$ 之一; - 如果将字符串的第 $i$ 个字符写在图中编号为 $i$ 的顶点上,则图中会存在一条回文哈密顿路径。 请注意,路径不必按 $1,2,\cdots,n$ 的编号顺序穿过顶点。 计算”好的“字符串的数量。

题目描述

You are given a simple undirected graph with $ n $ vertices, $ n $ is even. You are going to write a letter on each vertex. Each letter should be one of the first $ k $ letters of the Latin alphabet. A path in the graph is called Hamiltonian if it visits each vertex exactly once. A string is called palindromic if it reads the same from left to right and from right to left. A path in the graph is called palindromic if the letters on the vertices in it spell a palindromic string without changing the order. A string of length $ n $ is good if: - each letter is one of the first $ k $ lowercase Latin letters; - if you write the $ i $ -th letter of the string on the $ i $ -th vertex of the graph, there will exist a palindromic Hamiltonian path in the graph. Note that the path doesn't necesserily go through the vertices in order $ 1, 2, \dots, n $ . Count the number of good strings.

输入输出格式

输入格式


The first line contains three integers $ n $ , $ m $ and $ k $ ( $ 2 \le n \le 12 $ ; $ n $ is even; $ 0 \le m \le \frac{n \cdot (n-1)}{2} $ ; $ 1 \le k \le 12 $ ) — the number of vertices in the graph, the number of edges in the graph and the number of first letters of the Latin alphabet that can be used. Each of the next $ m $ lines contains two integers $ v $ and $ u $ ( $ 1 \le v, u \le n $ ; $ v \neq u $ ) — the edges of the graph. The graph doesn't contain multiple edges and self-loops.

输出格式


Print a single integer — number of good strings.

输入输出样例

输入样例 #1

4 3 3
1 2
2 3
3 4

输出样例 #1

9

输入样例 #2

4 6 3
1 2
1 3
1 4
2 3
2 4
3 4

输出样例 #2

21

输入样例 #3

12 19 12
1 3
2 6
3 6
3 7
4 8
8 5
8 7
9 4
5 9
10 1
10 4
10 6
9 10
11 1
5 11
7 11
12 2
12 5
12 11

输出样例 #3

456165084

Input

题意翻译

给你一个有 $n$ 个顶点的简单无向图(即无重边自环),$n$ 是偶数。你要在每个顶点上写一个字符。每个字符都应该是小写拉丁字母表中的头 $k$ 之一。 对于图上的一条路径,如果恰好访问每个顶点一次,则称其为哈密顿路径。对于一个字符串,如果从左到右和从右到左读是一样的,则称其为回文串。对于一条哈密顿路径,如果按照路径的顺序将顶点上的字符连成一个字符串,这个字符串是一个回文串,则称其为回文哈密顿路径。 对于一个长度为 $n$ 的字符串,若满足以下条件,则称其是”好的“: - 字符串中的每个字符都是小写拉丁字母表中的头 $k$ 之一; - 如果将字符串的第 $i$ 个字符写在图中编号为 $i$ 的顶点上,则图中会存在一条回文哈密顿路径。 请注意,路径不必按 $1,2,\cdots,n$ 的编号顺序穿过顶点。 计算”好的“字符串的数量。

加入题单

算法标签: