#P16081. [ICPC 2023 NAC] Who Watches the Watchmen?
[ICPC 2023 NAC] Who Watches the Watchmen?
题目描述
There are some sentry drones guarding a top-secret facility. Each sentry is stationary at some point in 3D space, and faces in some viewing direction.
With recent advances in artificial intelligence, the owners of the facility have come to the realization that the greatest threats to the facility are not intruders, but the sentries themselves! For security, they want to adjust the sentries such that every sentry is watching another sentry and every sentry is seen by exactly one other sentry.
It costs unit of energy to change the viewing direction of a sentry and units of energy to move a sentry to a new location. Note that these operations are independent. It costs units of energy in total to change both a sentry’s position and viewing direction. No two sentries can ever be at the same position at the end of a move. After being moved, a sentry’s position might not be on an integral lattice point.
A sentry at location facing direction can see any point for so long as there is no other sentry directly between it and the point. What is the minimum amount of energy needed to reposition the sentries so that each sentry can be seen by exactly one other sentry?
输入格式
The first line of input contains a single integer (), which is the number of sentries.
Each of the next lines contains six integers , , , , and , indicating that there is a sentry at facing in direction . All values will be in the range from to , inclusive. At least one of , or will be non-zero. No two sentries will be at the same position.
输出格式
Output a single integer, which is the minimum amount of energy needed to reposition the sentries so that each sentry can be seen by exactly one other sentry, or if it isn’t possible.
4
66 45 10 73 39 36
95 14 26 47 84 59
14 66 89 89 36 78
16 27 94 79 24 24
4