Making test data 8
Time limit1sMemory limit128 MB
Print a specific fixed graph: 98 vertices, 1501 edges forming a complete bipartite graph, using the exact listed edge order.
- Level
Easy2 of 10
- Topics
- Graph, Implementation, Brute force, Simulation
- 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 program that matches the intended approach from one that does not. It must also catch a program that is right on most inputs and wrong only on special cases.
This task is not to submit a solver. It is to make one test case.
You must make one input for the graph problem Mystery. must satisfy both of the following.
- Program A must not time out (TLE) on .
- Program B must time out (TLE) on .
Smaller data is better, so may contain at most integers, where .
Mystery is this problem. You are given an undirected graph with vertices and edges. Assign each vertex an integer in so that adjacent vertices get different integers. Find the smallest such .
The Mystery input format is as follows.
The first line has and . Each of the next lines has two integers and , an undirected edge.
The input must also satisfy the following.
- For every edge , , , , and no edge is listed twice.
Program A is RecursiveBacktracking. Program B is Gamble2. Both programs are in the hint.
Each program keeps a counter. If the counter exceeds , the run is TLE.
Many graphs meet the conditions. Print only the following graph.
- ,
- The graph is the complete bipartite graph whose parts are vertices through and vertices through .
- Print the edges in this order: for from to , and for each , for from to , print and on one line.
This graph uses integers. RecursiveBacktracking does not TLE on it. Gamble2 sets its counter to , so it always TLEs.
Write a program that prints this graph.
Input
This problem has no input.
Output
Print the graph above in Mystery input format.
The first line must be and separated by a space. Each of the next lines must have the two endpoints of an edge, separated by a space.
Hint
RecursiveBacktracking tries from to and stops at the first valid coloring. Vertices are colored in order . Vertex always gets color . After vertex is colored, the routine looks at the neighbors of vertex and tries colors through from smallest to largest. The counter grows by on each recursive call and by for each neighbor of the next vertex. If the counter exceeds , the run is TLE.
found = false
counter = 0
for X in 2 .. V:
cur[0 .. V-1] = -1
backtrack(0, 0)
if found:
break
if counter > 1000000:
TLE
output X and cur
backtrack(u, label):
if found:
return
counter += 1
cur[u] = label
if u == V-1:
found = true
return
ok[0 .. X-1] = true
for each neighbor v of vertex u+1:
counter += 1
if counter > 1000000:
return
if cur[v] != -1:
ok[cur[v]] = false
for j in 0 .. X-1:
if ok[j]:
backtrack(u+1, j)
Gamble2 ignores the graph and does only the following.
X = V
for i in 0 .. V-1:
label[i] = i
counter = 1000001
So Gamble2 always TLEs.