Pro.ID21848 TitleSmoking gun Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21848 AC4 Submit4 Ratio100.00% 时间&空间限制描述Andy: "Billy the Kid fired first!" Larry: "No, I'm sure I heard the first shot coming from John!" The arguments went back and forth during the trial after the big shoot-down, somewhere in the old wild west. Miraculously, everybody had survived (although there were serious injuries), but nobody could agree about the exact sequence of shots that had been fired. It was known that everybody had fired at most one shot, but everything had happened very fast. Determining the precise order of the shots was important for assigning guilt and penalties. But then the sheriff,Willy theWise, interrupted: "Look, I've got a satellite image from the time of the shooting, showing exactly where everybody was located. As it turns out, Larry was located much closer to John than to Billy the Kid, while Andy was located just slightly closer to John than to Billy the Kid. Thus, because sound travels with a finite speed of 340 meters per second, Larry may have heard John’s shot first, even if Billy the Kid fired first. But, although Andy was closer to John than to Billy the Kid, he heard Billy the Kid's shot first -- so we know for a fact that Billy the Kid was the one who fired first! Your task is to write a program to deduce the exact sequence of shots fired in situations like the above. 输入On the first line a positive integer: the number of test cases, at most 100. After that per test case:
If a person was never mentioned as S2 or S3, then it can be assumed that this person never fired, and only acted as a witness. No two persons are located in the same position. The test cases are constructed so that an error of less than 10-7 in one distance calculation will not affect the output. 输出Description Andy: "Billy the Kid fired first!" Larry: "No, I'm sure I heard the first shot coming from John!" The arguments went back and forth during the trial after the big shoot-down, somewhere in the old wild west. Miraculously, everybody had survived (although there were serious injuries), but nobody could agree about the exact sequence of shots that had been fired. It was known that everybody had fired at most one shot, but everything had happened very fast. Determining the precise order of the shots was important for assigning guilt and penalties. But then the sheriff,Willy theWise, interrupted: "Look, I've got a satellite image from the time of the shooting, showing exactly where everybody was located. As it turns out, Larry was located much closer to John than to Billy the Kid, while Andy was located just slightly closer to John than to Billy the Kid. Thus, because sound travels with a finite speed of 340 meters per second, Larry may have heard John’s shot first, even if Billy the Kid fired first. But, although Andy was closer to John than to Billy the Kid, he heard Billy the Kid's shot first -- so we know for a fact that Billy the Kid was the one who fired first! Your task is to write a program to deduce the exact sequence of shots fired in situations like the above. Input On the first line a positive integer: the number of test cases, at most 100. After that per test case:
If a person was never mentioned as S2 or S3, then it can be assumed that this person never fired, and only acted as a witness. No two persons are located in the same position. The test cases are constructed so that an error of less than 10-7 in one distance calculation will not affect the output. Output Per test case:
If multiple distinct orderings are possible, output "UNKNOWN" instead. If no ordering is compatible with the observations, output "IMPOSSIBLE" instead. Sample Input 3 Sample Output BillyTheKid John Source 样例输入3 样例输出BillyTheKid John 作者 |