Problem: There are N points in a two-dimensional plane. The initial coordinates of the i-th point are (x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the x\- or y\- axis. You are given a character d_i that represents the specific direction in which the i-th point moves, as follows:    * If d_i = `R`, the i-th point moves in the positive x direction;   * If d_i = `L`, the i-th point moves in the negative x direction;   * If d_i = `U`, the i-th point moves in the positive y direction;   * If d_i = `D`, the i-th point moves in the negative y direction.  You can stop all the points at some moment of your choice after they start moving (including the moment they start moving). Then, let x_{max} and x_{min} be the maximum and minimum among the x-coordinates of the N points, respectively. Similarly, let y_{max} and y_{min} be the maximum and minimum among the y-coordinates of the N points, respectively.  Find the minimum possible value of (x_{max} - x_{min}) \times (y_{max} - y_{min}) and print it.

Submission attempts (in order):
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

def want(n):

    xmax = float("-inf")
    xmin = float("inf")
    ymax = float("-inf")
    ymin = float("inf")

    if L:
        xmax = max(xmax,L_R - n)
        xmin = min(xmin,L_L - n)
        ymax = max(ymax,LR_U)
        ymin = min(ymin,LR_D)

    if R:
        xmax = max(xmax,R_R + n)
        xmin = min(xmin,R_L + n)
        ymax = max(ymax,LR_U)
        ymin = min(ymin,LR_D)

    if D:
        xmax = max(xmax,UD_R)
        xmin = min(xmin,UD_L)
        ymax = max(ymax,D_U - n)
        ymin = min(ymin,D_D - n)

    if U:
        xmax = max(xmax,UD_R)
        xmin = min(xmin,UD_L)
        ymax = max(ymax,U_U + n)
        ymin = min(ymin,U_D + n)

    return abs(xmax - xmin) * abs(ymax - ymin)


N = int(input())

UD_L = float("inf")
UD_R = float("-inf")
L_L = float("inf")
L_R = float("-inf")
R_L = float("inf")
R_R = float("-inf")

LR_D = float("inf")
LR_U = float("-inf")
D_D = float("inf")
D_U = float("-inf")
U_D = float("inf")
U_U = float("-inf")

U = False
D = False
L = False
R = False

for i in range(N):

    x,y,d = input().split()

    x = int(x)
    y = int(y)

    if d == "L" or d == "R":
        LR_D = min(LR_D,y)
        LR_U = max(LR_U,y)

        if d == "L":

            L_L = min(L_L,x)
            L_R = max(L_R,x)
            L = True

        else: #R

            R_L = min(R_L,x)
            R_R = max(R_R,x)
            R = True

    if d == "D" or d == "U":

        UD_L = min(UD_L,x)
        UD_R = max(UD_R,x)

        if d == "D":

            D_D = min(D_D,y)
            D_U = max(D_U,y)
            D = True

        else: #U

            U_D = min(U_D,y)
            U_U = max(U_U,y)
            U = True

t0 = 0
t3 = 2 * 10 ** 8
last = float("inf")
ans = 1000000000000000000000

while abs(last - ans) > 10 ** (-9):

    t1 = (t0 * 2 + t3 * 1) / 3
    t2 = (t0 * 1 + t3 * 2) / 3

    

    last = ans
    
    if want(t1) <= want(t2):
        ans = want(t1)
        t3 = t2

    else:
        ans = want(t2)
        t0 = t1

anst = '{:.1000g}'.format(ans)
if len(anst) > 20:
    anst = anst[:20]
print (anst)


from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

def want(n):

    xmax = float("-inf")
    xmin = float("inf")
    ymax = float("-inf")
    ymin = float("inf")

    if L:
        xmax = max(xmax,L_R - n)
        xmin = min(xmin,L_L - n)
        ymax = max(ymax,LR_U)
        ymin = min(ymin,LR_D)

    if R:
        xmax = max(xmax,R_R + n)
        xmin = min(xmin,R_L + n)
        ymax = max(ymax,LR_U)
        ymin = min(ymin,LR_D)

    if D:
        xmax = max(xmax,UD_R)
        xmin = min(xmin,UD_L)
        ymax = max(ymax,D_U - n)
        ymin = min(ymin,D_D - n)

    if U:
        xmax = max(xmax,UD_R)
        xmin = min(xmin,UD_L)
        ymax = max(ymax,U_U + n)
        ymin = min(ymin,U_D + n)

    
    return abs(xmax - xmin) * abs(ymax - ymin)

def my_round(val, digit=0):
    p = 10 ** digit
    return (val * p * 2 + 1) // 2 / p


N = int(input())

UD_L = float("inf")
UD_R = float("-inf")
L_L = float("inf")
L_R = float("-inf")
R_L = float("inf")
R_R = float("-inf")

LR_D = float("inf")
LR_U = float("-inf")
D_D = float("inf")
D_U = float("-inf")
U_D = float("inf")
U_U = float("-inf")

U = False
D = False
L = False
R = False

for i in range(N):

    x,y,d = input().split()

    x = int(x)
    y = int(y)

    if d == "L" or d == "R":
        LR_D = min(LR_D,y)
        LR_U = max(LR_U,y)

        if d == "L":

            L_L = min(L_L,x)
            L_R = max(L_R,x)
            L = True

        else: #R

            R_L = min(R_L,x)
            R_R = max(R_R,x)
            R = True

    if d == "D" or d == "U":

        UD_L = min(UD_L,x)
        UD_R = max(UD_R,x)

        if d == "D":

            D_D = min(D_D,y)
            D_U = max(D_U,y)
            D = True

        else: #U

            U_D = min(U_D,y)
            U_U = max(U_U,y)
            U = True

t0 = 0
t3 = 2 * 10 ** 8
last = float("inf")
ans = 1000000000000000000000

while abs(last - ans) > 10 ** (-100):

    t1 = Decimal((t0 * 2 + t3 * 1)) / Decimal(3)
    t2 = Decimal((t0 * 1 + t3 * 2)) / Decimal(3)

    

    last = ans
    
    if want(t1) <= want(t2):
        ans = want(t1)
        t3 = t2

    else:
        ans = want(t2)
        t0 = t1

    #print (last,ans,t1,t2)

if ans <= 10 ** (-9):
    ans = 0
print ('{:.20g}'.format(ans))


Verdicts: Wrong Answer

Accepted