A14525 | Palindromic Hamiltonian Path
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted