#P13002. [GCJ 2022 Finals] Goose, Goose, Ducks?
[GCJ 2022 Finals] Goose, Goose, Ducks?
题目描述
The first international Geese conference just wrapped up, and even though it should have been a happy occasion, it was bittersweet. The organizers found a paper with detailed plans of a duck infiltration. Now, they are trying to identify the infiltrating group from among the attendees.
The document that they found contained a list of triples of integers meaning the ducks would meet exactly seconds after the start of the conference at point , which is meters east and meters north of the center of the conference floor. Each goose may or may not have been at those specific points at those specific times, but every duck certainly was.
Both ducks and geese walk at a maximum speed of one meter per second, which means an attendee that is at point at time can reach any point of the form by time as long as . Each attendee's position at time 0 can be any point, independently of the other attendees.
After the discovery, the group held a questioning session to try to identify the ducks. During that session, attendees issued a series of statements, one at a time. The -th of those, in the order they were issued, was made by attendee , claiming that both they and attendee were at point exactly seconds after the start of the conference. Points in statements may or may not be points where duck meetings happened.
Statements from geese are always true, but ducks may lie. Moreover, ducks know which attendees are ducks and which are geese. To avoid getting caught easily, ducks only make statements that are consistent with all statements previously made by geese. Note that statements made by geese are consistent with all ducks being at all duck meetings.
It may not be possible to determine all the ducks with the information provided. However, knowing the minimum number of ducks will at least provide a lower bound on the level of duck activity. Note that there was at least one duck. Find this minimum number of ducks.
Formally, a hypothesis is a partition of all attendees into a set of ducks (named -ducks) and geese (named -geese). is consistent with a set of statements if there exists a path for each attendee moving at most one meter per second such that:
- all -ducks were at all duck meetings and
- for each statement in claiming that saw at point at time , both and 's paths went through point at time .
A hypothesis is feasible under a set of statements if:
- -ducks is not empty (i.e., there was at least one duck),
- the subset of all statements from made by members of -geese is consistent with (i.e., statements from geese are always true), and
- for each statement made by a member of -ducks, if is the subset of statements made by members of -geese issued before , there exists a hypothesis (which may or may not be equal to ) such that is consistent with (i.e., ducks do not contradict previous statements made by geese).
Notice that the hypotheses such that -ducks contains all attendees is always feasible.
Find the minimum size of -ducks over all feasible hypotheses .
输入格式
The first line of the input gives the number of test cases, . test cases follow. Each test case starts with a line containing three integers, , , and , representing the numbers of attendees, duck meetings, and statements, respectively. The next lines each describe a different duck meeting with three integers , , and , representing that there was a meeting at point , held exactly seconds after the start of the conference. Then, the last lines of a test case each describe a statement. The -th of these lines describes the -th issued statement with five integers , , , , and , representing that attendee stated that they and attendee were both at point exactly seconds after the start of the conference.
输出格式
For each test case, output one line containing Case #x: y
, where is the test case number (starting from 1) and is the minimum number of ducks that might have infiltrated the conference.
2
2 1 2
1 2 3
1 2 1 1 1
2 1 2 2 2
4 2 4
4 3 10
-4 -3 20
1 3 4 3 11
2 4 0 0 16
3 1 6 3 9
4 2 0 0 16
Case #1: 1
Case #2: 2
提示
Sample Explanation
In Sample Case #1, attendee 1 being the only duck is a feasible hypothesis.
In Sample Case #2, attendees 2 and 4 being the only ducks is a feasible hypothesis. Note that there is at least one duck, so all attendees being geese is not feasible.
Limits
- .
- , for all .
- , for all .
- , for all .
- , for all .
- $(\mathbf{X}_i - \mathbf{X}_{i+1})^2 + (\mathbf{Y}_i - \mathbf{Y}_{i+1})^2 \leq (\mathbf{C}_i - \mathbf{C}_{i+1})^2$, for all .
- , for all .
- , for all .
- , for all .
- , for all .
- , for all .
- , for all .
- $(\mathbf{A}_j, \mathbf{B}_j, \mathbf{U}_j, \mathbf{V}_j, \mathbf{D}_j) \neq (\mathbf{A}_k, \mathbf{B}_k, \mathbf{U}_k, \mathbf{V}_k, \mathbf{D}_k)$, for all .
Test Set 1 (11 Pts, Visible Verdict)
- Time limit: 20 seconds.
- .
- .
- .
Test Set 2 (24 Pts, Hidden Verdict)
- Time limit: 60 seconds.
- .
- .
- .