Under construction

Still being built. Things may change

Maximum Detour

Time limit1sMemory limit128 MB

Summary
Given the vertices of a polygonal path in order, compute the largest ratio of along-path length to straight-line distance over all vertex pairs.
Level

Medium4 of 10

Topics
Geometry, Brute force, Prefix sum
Solved
No attempts yet

Problem

The geometric graph G=(V,E)G = (V, E) in this problem is a path of NN vertices v1,v2,…,vNv_1, v_2, \ldots, v_N, with one edge joining viv_i and vi+1v_{i+1} for every ii with 1≤i≤N−11 \le i \le N-1. Each vertex is a point on the plane, and each edge is the straight segment between the two points it joins.

Read GG as a road network you may travel only along its edges. Getting from one vertex to another is then usually longer than the straight line between them, and the detour is the ratio of the two. For two vertices viv_i and vjv_j with i<ji < j,

D(G,vi,vj)=dG(vi,vj)/d(vi,vj)D(G, v_i, v_j) = d_G(v_i, v_j) / d(v_i, v_j)

where d(p,q)d(p, q) is the Euclidean distance between two points pp and qq, and dG(vi,vj)=d(vi,vi+1)+d(vi+1,vi+2)+…+d(vj−1,vj)d_G(v_i, v_j) = d(v_i, v_{i+1}) + d(v_{i+1}, v_{i+2}) + \ldots + d(v_{j-1}, v_j) is the length of the walk along the path. The maximum detour D(G)D(G) is the largest detour over all pairs of distinct vertices of GG.

The figure shows a geometric graph GG that is a path of 7 vertices v1,…,v7v_1, \ldots, v_7. The numbers are Euclidean distances between pairs of vertices, so d(v1,v2)=10d(v_1, v_2) = 10 and d(v1,v4)=4d(v_1, v_4) = 4. Here D(G,v1,v4)=dG(v1,v4)/d(v1,v4)=(10+10+9)/4=29/4D(G, v_1, v_4) = d_G(v_1, v_4) / d(v_1, v_4) = (10 + 10 + 9) / 4 = 29 / 4.

You are given the NN points of one such path in order. Compute the maximum detour D(G)D(G).

Input

The first line has the number of test cases TT (1≤T≤201 \le T \le 20). Each test case begins with a line holding the number of vertices NN (2≤N≤100002 \le N \le 10000), followed by NN lines holding the coordinates of v1,v2,…,vNv_1, v_2, \ldots, v_N in that order, one vertex per line. The two integers on a line are separated by one space. Every coordinate is an integer between −10000-10000 and 1000010000. No two consecutive vertices are the same point, so every edge has positive length.

Output

Print one line for each test case.

If D(G)D(G) is at least 1000, print TOO LARGE. Otherwise print D(G)D(G) rounded to two digits after the decimal point, always writing both digits: print 1.00, not 1.

The path may cross itself. Two vertices that are not neighbours may even lie on the same point, and then the distance between them is 0 and D(G)D(G) grows without bound, so the answer is TOO LARGE.

In every test case the exact value of D(G)D(G) is farther than 10−610^{-6} from 1000, and farther than 10−610^{-6} from any value halfway between two multiples of 0.01 such as 0.005, 0.015 or 0.025. The rounding direction is never ambiguous.

Examples2

  1. Example 1

    Input
    3
    4
    0 0
    0 1
    1 1
    1 0
    10
    -91 76
    -87 -41
    44 -12
    -56 49
    -86 50
    92 -14
    -6 -100
    -2 83
    -2 20
    -60 -26
    3
    0 0
    3000 0
    0 1
    
    Expected output
    3.00
    29.82
    TOO LARGE
    
  2. Example 2

    Input
    2
    3
    0 0
    0 3
    4 0
    2
    -10000 -10000
    10000 10000
    
    Expected output
    2.00
    1.00