Under construction

Still being built. Things may change

A Classic Myth: Flatland Superhero

Time limit1sMemory limit128 MB

Summary
For each swarm of points, compute the minimum area of a parallelogram that contains all of them, using the rotating calipers method on the convex hull.
Level

Hard8 of 10

Topics
Geometry, Divide and conquer, Math, Sorting
Solved
No attempts yet

Problem

Flatland needs a superhero! Recently, swarms of killer ants have been invading Flatland, and no one there can figure out how to stop these dastardly denizens. Fortunately, you — as a higher-dimensional being — have the chance to become a hero in the eyes of Flatland's citizens. Your job is to "freeze" each swarm of ants by trapping it inside a parallelogram.

For every swarm you must find an enclosing parallelogram of minimum area. Once a minimum-area parallelogram is placed around a swarm, the ants are effectively frozen in place and can no longer terrorize the inhabitants of the plane.

Write a program that, for each swarm, reports the area of its minimum-area enclosing parallelogram.

Input

The first line contains a single integer ss (1≤s≤201 \le s \le 20), the number of ant swarms.

Each swarm is described as follows:

  • A line with a single integer nn (4≤n≤10004 \le n \le 1000), the number of ants in the swarm.
  • nn lines follow, each giving the position of one ant as two numbers xx and yy (−1000≤x≤1000-1000 \le x \le 1000, −1000≤y≤1000-1000 \le y \le 1000) separated by a space.

Within a single swarm, no two ants share the same (x,y)(x, y) location. Each swarm is handled independently of the others. All coordinates are given in fixed-point decimal notation with exactly four digits after the decimal point (for example, dddd.dddd). A swarm may admit several distinct parallelograms that all achieve the minimum area, but only that minimum area is asked for, so the answer is unique.

Output

For each swarm, print one line in the form:

Swarm i Parallelogram Area: A

where ii (1≤i≤s1 \le i \le s) is the swarm number and AA is the minimum area of an enclosing parallelogram for that swarm. Perform every computation with 64-bit IEEE floating-point numbers, and print AA in fixed-point decimal notation rounded to exactly four digits after the decimal point.

Examples2

  1. Example 1

    Input
    2
    6
    0.0000 0.0000
    -0.5000 -0.5000
    -1.0000 0.0000
    -0.7000 -7.0000
    -1.0000 -1.0000
    0.0000 -1.0000
    5
    2.0000 2.0000
    0.0000 0.0000
    0.5000 2.0000
    1.0000 1.0000
    1.5000 0.0000
    
    Expected output
    Swarm 1 Parallelogram Area: 7.0000
    Swarm 2 Parallelogram Area: 3.0000
    
  2. Example 2

    Input
    1
    4
    0.0000 0.0000
    2.0000 0.0000
    2.0000 2.0000
    0.0000 2.0000
    
    Expected output
    Swarm 1 Parallelogram Area: 4.0000