| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 40 초 (추가 시간 없음) | 1024 MB | 87 | 26 | 21 | 38.182% |
Ada baked some cookies for her birthday party where she invited $\mathbf{N}$ guests, labeled 1ドル$ to $\mathbf{N}$. 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 $\mathbf{M}$ 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 $\mathbf{K}$ 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.
The first line of the input gives the number of test cases, $\mathbf{T}$. $\mathbf{T}$ test cases follow.
The first line of each test case contains three integers $\mathbf{N},ドル $\mathbf{M},ドル and $\mathbf{K}$: the number of guests, the number of witness statements, and the maximum number of cookie stealers, respectively.
The next $\mathbf{M}$ lines describe the witness statements. The $i$-th line contains two integers $\mathbf{A_i}$ and $\mathbf{B_i},ドル which means the witness statement Guest $\mathbf{A_i}$: "Guest $\mathbf{B_i}$ did not steal the cookies."
For each test case, output one line containing Case #$x$: $y$, where $x$ is the test case number (starting from 1) and $y$ is the number of guests that can be proved to be innocent.
2 3 2 1 1 2 2 3 3 3 1 1 2 2 3 3 1
Case #1: 2 Case #2: 3
In Sample Case #1, there are $\mathbf{N}=3$ guests, $\mathbf{M}=2$ witness statements and at most $\mathbf{K}=1$ cookie stealer. The witness statements are:
Now we consider all possible arrangements on whether each guest is a cookie stealer.
| Guest 1 | Guest 2 | Guest 3 | Possible? | |
|---|---|---|---|---|
| Scenario #1 | Innocent | Innocent | Innocent | YES |
| Scenario #2 | CS | Innocent | Innocent | YES |
| Scenario #3 | Innocent | CS | Innocent | NO |
| Scenario #4 | Innocent | Innocent | CS | NO |
These are all the scenarios where there is at most $\mathbf{K}=1$ cookie stealer (CS). Scenario #3 is impossible because Guest 1 is innocent and states that Guest 2 is innocent, but Guest 2 turns out to be the cookie stealer. Same reasoning for scenario #4.
For the remaining scenarios, we see that Guest 2 and 3 are always innocent, so the answer is 2ドル$.
2 3 2 2 1 2 2 3 3 3 2 1 2 2 3 3 2
Case #1: 1 Case #2: 2
Contest > Google > Kick Start > Google Kick Start 2022 > Round D D번