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

25002번 - Board Game 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3.5 초 256 MB169457.143%

문제

Today, Sophie received a new board game, whose key element is establishing trade links between cities. There are $n$ cities with coordinates $(x_1,y_1),(x_2,y_2),\ldots,(x_n,y_n)$ on the board, no two of them sharing both coordinates. Each city produces a good of one type. Trade links can be established only between cities producing goods of different kinds. For establishing such a link between a pair of cities with coordinates $(x_i,y_i)$ and $(x_j,y_j),ドル the player receives $$(x_i-x_j)^2+(y_i-y_j)^2$$ points.

Sophie would like to know which trade link would grant her the most points. Write a program that: reads the board description, determines the trade link that maximizes the number of points, and prints this number to the standard output.

입력

In the first line of input, there is an integer $n$ (2ドル \le n \le 250,000円$) that specifies the number of cities on the board. Each of the $n$ lines that follow describes a single city. A city's description consists of a triple of integers $x_i, y_i, t_i$ ($-1,000円 ,000円,000円 \leq x_i,y_i \leq 1,000円,000円,000円,ドル 1ドル\leq t_i \leq n$) separated by single spaces; the numbers $x_i, y_i$ are the $i$-th city's coordinates, whereas $t_i$ is the type of good that it produces.

More than one type of good is produced overall, and no two cities share both coordinates.

출력

The first and only line of output should contain the maximum number of points that Sophie can receive for a single trade link.

제한

예제 입력 1

5
5 4 2
-2 -2 1
10 10 1
8 5 3
5 8 3

예제 출력 1

149

노트

The trade link that maximize the number of points links the cities with coordinates $(-2,-2)$ and $(8,5)$. This link yields 149ドル = 10^2 + 7^2$ points. There is also another link that yields the same amount of points: between the cities with coordinates $(-2,-2)$ and $(5,8)$.

출처

ICPC > Regionals > Europe > Central European Regional Contest > Poland Collegiate Programming Contest > AMPPZ 2015 G번

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

출처

대학교 대회

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

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