All Friends
Time limit1sMemory limit128 MB
Count the maximal cliques of an undirected graph with up to 128 vertices, reporting "Too many" when the count exceeds 1000.
- Level
Hard8 of 10
- Topics
- Graph, Backtracking, Brute force, Combinatorics
- Solved
- No attempts yet
Problem
Sociologists are interested in the phenomenon of "friendship". To study it, they analyze various groups of people. For every two persons in a group they record whether or not the two are friends. Friendship is assumed to be symmetric: if is a friend of , then is also a friend of .
The sociologists focus on sets of friends. A set of people is a set of friends if every two persons in are friends with each other. Because there can be far too many such sets, they study only the maximal ones. A set of friends is maximal if no further person can be added to while keeping it a set of friends; equivalently, every person not in fails to be a friend of at least one member of .
For each group, determine the number of maximal sets of friends. If this number is greater than , the group is too complicated to study and you only need to report that fact.
Input
The input consists of several groups (test instances), separated by single blank lines.
The first line of each group contains two integers and (): the number of persons in the group and the number of friendship relations. Persons are numbered from to . Each of the next lines contains two integers and (, ), meaning that persons and are friends. Each friendship is listed at most once.
Output
For each group, output on its own line the number of maximal sets of friends in that group. If this number is greater than , output the line Too many maximal sets of friends. instead.