The Bad Scientist
Time limit1sMemory limit128 MB
Given a graph of contradictions, delete at most k vertices to remove all edges and report the smallest such set size, or IMPOSSIBLE.
- Level
Hard8 of 10
- Topics
- Graph, Brute force, Combinatorics, Backtracking
- Solved
- No attempts yet
Problem
Sanggeun is a scientist who fabricates his experimental results. He has always tampered with them so carefully that for the past several years nobody has ever caught him. But after going unsuspected for so long, Sanggeun has grown careless with his forgeries.
As a result, his latest paper contains theories that contradict one another. To remove these contradictions, Sanggeun decides to delete some of the theories from the paper. Whenever two theories contradict each other, deleting at least one of the two makes that contradiction disappear.
Meanwhile, Sanggeun's colleague Seonjin has watched all of his experiments over the years. Because of that, there is a limit to how many theories Sanggeun can delete before Seonjin grows suspicious.
Input
The first line contains the number of test cases . ()
Each test case is given as follows.
- The first line contains the number of theories in the paper. ()
- The second line contains , the maximum number of theories that can be deleted without arousing suspicion. ()
- The third line contains , the number of contradicting pairs of theories. ()
- Each of the next lines contains two theories and that contradict each other. ()
The theories are numbered from to , and no pair of theories is given more than once.
Output
For each test case, print on its own line the minimum number of theories that must be deleted so that the paper contains no contradictions.
If that minimum exceeds , so that suspicion cannot be avoided, print IMPOSSIBLE instead.