Logo
(追記) (追記ここまで)

28156번 - Who Watches the Watchmen? 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 2048 MB118161614.035%

문제

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 1ドル$ unit of energy to change the viewing direction of a sentry and 1ドル,000円$ units of energy to move a sentry to a new location. Note that these operations are independent. It costs 1ドル,001円$ 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 $(x,y,z)$ facing direction $(vx,vy,vz)$ can see any point $(x + t \cdot vx, y + t \cdot vy, z + t \cdot vz)$ for $t \ge 0$ 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 $n$ (1ドル \le n \le 500$), which is the number of sentries.

Each of the next $n$ lines contains six integers $x,ドル $y,ドル $z,ドル $vx,ドル $vy$ and $vz,ドル indicating that there is a sentry at $(x,y,z)$ facing in direction $(vx,vy,vz)$. All values will be in the range from $-10^6$ to 10ドル^6,ドル inclusive. At least one of $vx,ドル $vy$ or $vz$ 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 $-1$ if it isn't possible.

제한

예제 입력 1

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

예제 출력 1

4

힌트

출처

ICPC > Regionals > North America > North America Championship > North America Championship 2023 M번

  • 문제를 만든 사람: Arnav Sastry
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /