[Solution] Suspects and Witnesses Round D 2022 | Kick Start 2022 Solution
Problem
Ada baked some cookies for her birthday party where she invited guests, labeled to . When all the guests have arrived and the party is about to start, something terrible has happened — someone stole the cookies!
Ada puts on her detective hat and starts questioning her guests. She gathered witness statements of the form: Guest x: "Guest y did not steal the cookies."
Ada knows that, if a guest is innocent (did not steal a cookie), then all their witness statements must be true. Note that Ada does not know whether any statement made by a cookie stealer is correct.
Lastly, Ada has an informant who told her there can be at most cookie stealers. With this information, can you help Ada find out the number of guests who can be proved to be innocent?
Note that it is possible that no guest actually stole the cookies, and Ada simply forgot how many cookies she baked.
Input
The first line of the input gives the number of test cases, . test cases follow.
The first line of each test case contains three integers , , and : the number of guests, the number of witness statements, and the maximum number of cookie stealers, respectively.
The next lines describe the witness statements. The -th line contains two integers and , which means the witness statement Guest : "Guest did not steal the cookies."
Output
For each test case, output one line containing Case #:
, where is the test case number (starting from 1) and is the number of guests that can be proved to be innocent.
Limits
Time limit: 40 seconds.
Memory limit: 1 GB.
.
.
.
, for all .
, for all .
, for all .
, for all .
Test Set 1
.
Test Set 2
.
No comments:
Post a Comment