Problems > Hull Edge Energy

Hull Edge Energy

Difficulty: 1800 6000 ms 128 MB

geometry

Build the convex hull and print the sum of the SQUARED lengths of its edges (an integer, avoiding floating point). A hull of fewer than 2 vertices has energy 0.

Input: the first line has N; the next N lines have distinct points x y.

Output: the sum of squared hull-edge lengths.

Constraints:

  • 1 ≤ N ≤ 105
  • |coordinates| ≤ 106

Sample Tests

Input 1
4
0 0
3 0
3 4
0 4
Output 1
50
Input 2
2
0 0
1 1
Output 2
4

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.