Problem:
Score : 600 points

Problem Statement

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.

Constraints

1 \leq N \leq 10^5

-10^8 \leq x_i,\ y_i \leq 10^8

x_i and y_i are integers.

d_i is R, L, U, or D.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1 d_1
x_2 y_2 d_2
.
.
.
x_N y_N d_N

Output

Print the minimum possible value of (x_{max} - x_{min}) \times (y_{max} - y_{min}).

The output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-9}.

Sample Input 1

2
0 3 D
3 0 L

Sample Output 1

0

After three seconds, the two points will meet at the origin. The value in question will be 0 at that moment.

Sample Input 2

5
-7 -10 U
7 -6 U
-8 7 D
-3 3 D
0 -6 R

Sample Output 2

97.5

The answer may not be an integer.

Sample Input 3

20
6 -10 R
-4 -9 U
9 6 D
-3 -2 R
0 7 D
4 5 D
10 -10 U
-1 -8 U
10 -6 D
8 -5 U
6 4 D
0 3 D
7 9 R
9 -4 R
3 10 D
1 9 U
1 -6 U
9 -8 R
6 7 D
7 -3 D

Sample Output 3

273

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long MIN = Integer.MIN_VALUE;
        long MAX = Integer.MAX_VALUE;

        long rmax = Integer.MIN_VALUE;
        long rmin = Integer.MAX_VALUE;
        long lmax = Integer.MIN_VALUE;
        long lmin = Integer.MAX_VALUE;
        long lrmax = Integer.MIN_VALUE;
        long lrmin = Integer.MAX_VALUE;
        long umax = Integer.MIN_VALUE;
        long umin = Integer.MAX_VALUE;
        long dumax = Integer.MIN_VALUE;
        long dumin = Integer.MAX_VALUE;
        long dmax = Integer.MIN_VALUE;
        long dmin = Integer.MAX_VALUE;


        for(int i=0; i<n; i++) {
            int x = sc.nextInt() * 2;
            int y = sc.nextInt() * 2;
            char d = sc.next().charAt(0);
            if(d == 'U') {
                umax = Math.max(umax, y);
                umin = Math.min(umin, y);
                lrmax = Math.max(lrmax, x);
                lrmin = Math.min(lrmin, x);
            }
            if(d == 'D') {
                dmax = Math.max(dmax, y);
                dmin = Math.min(dmin, y);
                lrmax = Math.max(lrmax, x);
                lrmin = Math.min(lrmin, x);
            }
            if(d == 'L') {
                dumax = Math.max(dumax, y);
                dumin = Math.min(dumin, y);
                lmax = Math.max(lmax, x);
                lmin = Math.min(lmin, x);
            }
            if(d == 'R') {
                dumax = Math.max(dumax, y);
                dumin = Math.min(dumin, y);
                rmax = Math.max(rmax, x);
                rmin = Math.min(rmin, x);
            }
        }


        Set<Long> set = new HashSet<>();
        set.add(0L);

        if(umax != MIN && dumax != MIN) {
            set.add(dumax - umax);
        }
        if(dmax != MIN && dumax != MIN) {
            set.add(dmax - dumax);
        }
        if(dmax != MIN && umax != MIN) {
            set.add((dmax - umax)/2);
        }
        if(umin != MAX && dumin != MAX) {
            set.add(dumin - umin);
        }
        if(dmin != MAX && dumin != MAX) {
            set.add(dmin - dumin);
        }
        if(dmin != MAX && umin != MAX) {
            set.add((dmin - umin)/2);
        }
        if(rmax != MIN && lrmax != MIN) {
            set.add(lrmax - rmax);
        }
        if(lmax != MIN && lrmax != MIN) {
            set.add(lmax - lrmax);
        }
        if(lmax != MIN && rmax != MIN) {
            set.add((lmax - rmax)/2);
        }
        if(rmin != MAX && lrmin != MAX) {
            set.add(lrmin - rmin);
        }
        if(lmin != MAX && lrmin != MAX) {
            set.add(lmin - lrmin);
        }
        if(lmin != MAX && rmin != MAX) {
            set.add((lmin - rmin)/2);
        }

        double res = 1e+200;
        for(long t : set) {
            if(t < 0) continue;
            double u = max(dumax, umax+t, dmax-t);
            double d = min(dumin, umin+t, dmin-t);
            double r = max(lrmax, rmax+t, lmax-t);
            double l = min(lrmin, rmin+t, lmin-t);
            res = Math.min(res, (u-d) * (r-l));
        }
        System.out.println(res/4);
    }

    static long max(long a, long b, long c) {
        return Math.max(a, Math.max(b, c));
    }
    static long min(long a, long b, long c) {
        return Math.min(a, Math.min(b, c));
    }


}