CF1569F.Palindromic Hamiltonian Path
NOI/NOI+/CTSC
通过率:0%
时间限制:5.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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,…,n.
Count the number of good strings.
给你一个包含 n 个顶点的简单无向图,其中 n 为偶数。你需要在每个顶点上写一个字母,该字母必须是拉丁字母表前 k 个字母之一。
图中的一条路径称为哈密顿路径,当且仅当它恰好经过每个顶点一次。一个字符串称为回文串,当且仅当它从左到右读与从右到左读完全相同。图中的一条路径称为回文路径,当且仅当按路径中顶点的顺序写出其上的字母所构成的字符串是一个回文串。
一个长度为 n 的字符串称为好字符串,如果满足:
- 字符串中每个字符均为拉丁字母表前 k 个小写字母之一;
- 若将该字符串的第 i 个字符写在图中第 i 个顶点上,则图中存在一条回文哈密顿路径。
注意:该路径不一定按顶点编号顺序 1,2,…,n 经过顶点。
请计算好字符串的个数。
输入格式
The first line contains three integers n, m and k (2≤n≤12; n is even; 0≤m≤2n⋅(n−1); 1≤k≤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≤v,u≤n; v=u) — the edges of the graph. The graph doesn't contain multiple edges and self-loops.
第一行包含三个整数 n、m 和 k(2≤n≤12;n 为偶数;0≤m≤2n⋅(n−1);1≤k≤12)—— 分别表示图中顶点的数量、边的数量,以及可使用的拉丁字母表前 k 个字母的数量。
接下来的 m 行中,每行包含两个整数 v 和 u(1≤v,u≤n;v=u)—— 表示图中的一条边。该图不含重边和自环。
输出格式
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
输入解题思路,AI测评打分。不知道怎么写?