A graph that times out coloring backtracking
Time limit1sMemory limit128 MB
Print one fixed graph: a 55-vertex clique joined by a path, chosen to make a backtracking coloring solver time out.
- Level
Easy1 of 10
- Topics
- Graph, Implementation, Brute force
- Solved
- No attempts yet
Problem
Programming contests are common. Writing a good contest problem is hard, and making the test data is the hardest part. Good test data must separate a solution that matches the intended approach from one that does not. It must also catch a program that is right on most inputs but slow or wrong on a special case.
This task does not ask you to submit a solver. It asks you to print one input for a graph coloring problem.
The coloring problem is as follows. You are given a simple undirected graph with vertices and edges. Assign each vertex a label in so that adjacent vertices get different labels, and find the smallest such .
Two programs try to solve that coloring problem: Gamble1 and RecursiveBacktracking. Each keeps a counter of work. If the counter exceeds , the run is a time limit exceeded (TLE).
Gamble1 sets , labels vertex with , and sets the counter to . On a valid input it never exceeds the time limit.
RecursiveBacktracking tries from to and stops at the first that admits a valid labeling. For each it labels vertex with , then for vertices in order it tries labels from smallest to largest, skipping labels already used by a labeled neighbor, and backtracks on failure. Each time it assigns a label to a vertex, the counter increases by .
The data you print must satisfy all of the following.
- Gamble1 does not TLE.
- RecursiveBacktracking does TLE.
- The data consists of at most integers.
- You print the unique graph specified in the output section, in that exact format. Any other graph is wrong.
Input
There is no input.
The coloring problem uses this input format. The first line has and . Each of the next lines has the endpoints , of an edge. The input must satisfy:
- For every edge , , , , and each edge appears once.
Output
Print the following graph.
On the first line print .
Vertices are through .
Vertices through form a complete graph. For and , print on its own line, with increasing, and for a fixed with increasing.
Then print the edges of the path . For , print on its own line.
This graph has vertices and edges, so it uses integers. It satisfies and . It has no loops and no parallel edges.
The graph contains a clique of size , so any valid is at least . While RecursiveBacktracking tries upward, the counter exceeds . Gamble1's counter stays .