#P5271. Graph Edge Decomposition into K_p Cliques
Graph Edge Decomposition into K_p Cliques
Graph Edge Decomposition into K_p Cliques
Given a prime (p) and a positive integer (k), consider a complete undirected graph on (p^k) vertices labeled from (0) to (p^k-1). The graph contains an edge between every pair of vertices. Your task is to partition the edge set of this graph into cliques (complete subgraphs) of size (p) such that each edge of the original graph belongs to exactly one clique.
It can be verified that the required number of cliques is given by:
[ \frac{\frac{p^k(p^k-1)}{2}}{\frac{p(p-1)}{2}} = \frac{p^k(p^k-1)}{p(p-1)}]
A well–known construction uses the affine space structure of ( \mathbb{F}_p^k ) (since (p^k) is the size of a finite field) where the set of all lines (affine subspaces of dimension 1) forms a partition of the pairs of points. (Note that in an affine space of dimension (k) over (\mathbb{F}_p), any two distinct points lie on a unique line.)
Your program should output the number of cliques first, and then each clique on a separate line. Each clique is represented by the sorted list of its vertices (in increasing order) separated by a single space.
inputFormat
The input consists of a single line containing two integers (p) and (k), where (p) is a prime and (k) is a positive integer. (p^k) is the number of vertices in the complete graph.
outputFormat
First, output the number of cliques. Then, for each clique, output a line containing the vertices in that clique in strictly increasing order separated by a single space. Each clique should be a set of (p) vertices, and the collection of cliques must partition the edge set of the complete graph.
sample
3 1
1
0 1 2
</p>