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: Wrong Answer)

import java.io.*;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

public class Main {

    static int N;
    static int[] X, Y;
    static char[] D;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        X = new int[N];
        Y = new int[N];
        D = new char[N];
        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt() * 2;
            Y[i] = sc.nextInt() * 2;
            D[i] = sc.next().charAt(0);
        }

        System.out.println(BigDecimal.valueOf(solve()).toPlainString());
    }

    static double solve() {
        Widthes w = new Widthes();
        Widthes h = new Widthes();
        for (int i = 0; i < N; i++) {
            int x = X[i];
            int y = Y[i];
            char d = D[i];
            if( d == 'L' ) {
                w.addLeft(x);
                h.addFix(y);
            } else if( d == 'R' ) {
                w.addRight(x);
                h.addFix(y);
            } else if( d == 'U' ) {
                w.addFix(x);
                h.addRight(y);
            } else {
                w.addFix(x);
                h.addLeft(y);
            }
        }

        Set<Integer> events = new HashSet<>();
        events.addAll( w.getEvents() );
        events.addAll( h.getEvents() );
        events.add(0);

        debug(events);

        long min = Long.MAX_VALUE;
        for (int t : events) {
            min = Math.min(min, (long)w.width(t) * h.width(t));
        }
        return (double)min/4;
    }

    static int INF = 1_000_000_000;

    static class Widthes {
        int lmin = INF, lmax = -INF;
        int rmin = INF, rmax = -INF;
        int fmin = INF, fmax = -INF;

        public int width(int t) {
            int min = min(lmin-t, fmin, rmin+t);
            int max = max(lmax-t, fmax, rmax+t);
            return max-min;
        }

        public List<Integer> getEvents() {
            List<Integer> events = new ArrayList<>();
            events.add((lmax-rmax)/2);
            events.add(fmax-rmax);
            events.add(lmax-fmax);
            events.add((lmin-rmin)/2);
            events.add(fmin-rmin);
            events.add(lmin-fmin);
            return events.stream().filter(t -> t >= 0 ).collect(Collectors.toList());
        }

        public void addLeft(int a) {
            lmin = Math.min(lmin, a);
            lmax = Math.max(lmax, a);
        }

        public void addRight(int a) {
            rmin = Math.min(rmin, a);
            rmax = Math.max(rmax, a);
        }

        public void addFix(int a) {
            fmin = Math.min(fmin, a);
            fmax = Math.max(fmax, a);
        }
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        int[] nextIntArray(int n, int delta) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt() + delta;
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

    static <A> void writeLines(A[] as, Function<A, String> f) {
        PrintWriter pw = new PrintWriter(System.out);
        for (A a : as) {
            pw.println(f.apply(a));
        }
        pw.flush();
    }

    static void writeLines(int[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (int a : as) pw.println(a);
        pw.flush();
    }

    static void writeLines(long[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (long a : as) pw.println(a);
        pw.flush();
    }

    static int max(int... as) {
        int max = Integer.MIN_VALUE;
        for (int a : as) max = Math.max(a, max);
        return max;
    }

    static int min(int... as) {
        int min = Integer.MAX_VALUE;
        for (int a : as) min = Math.min(a, min);
        return min;
    }

    static void debug(Object... args) {
        StringJoiner j = new StringJoiner(" ");
        for (Object arg : args) {
            if (arg instanceof int[]) j.add(Arrays.toString((int[]) arg));
            else if (arg instanceof long[]) j.add(Arrays.toString((long[]) arg));
            else if (arg instanceof double[]) j.add(Arrays.toString((double[]) arg));
            else if (arg instanceof Object[]) j.add(Arrays.toString((Object[]) arg));
            else j.add(arg.toString());
        }
        System.err.println(j.toString());
    }
}