luogu#P2819. 图的 m 着色问题
图的 m 着色问题
Background
Given an undirected connected graph and different colors, color each vertex of using these colors, with each vertex assigned exactly one color. If there exists a coloring such that the two vertices of every edge in have different colors, then the graph is called -colorable. The graph -coloring problem is: for a given graph and colors, find all distinct colorings.
Problem Description
For a given undirected connected graph and different colors, write a program to compute all distinct colorings of the graph.
Input Format
The first line contains positive integers , indicating that the given graph has vertices and edges, and there are colors. The vertices are labeled . The next lines each contain positive integers , representing an edge of the graph .
Output Format
At the end of the program, output the number of computed distinct coloring schemes.
5 8 4
1 2
1 3
1 4
2 3
2 4
2 5
3 4
4 5
48
Hint
The data guarantees , .
When is large, it is guaranteed that is sufficiently large.
It is guaranteed that the answer does not exceed .
The testdata is randomly sampled from valid data that meet the above conditions.
Translated by ChatGPT 5