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 Common Lisp (SBCL 1.1.14) (judge verdict: Wrong Answer)

;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setf minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return (if minus (- result) result))))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read))
         (xs- (make-array n :fill-pointer 0 :element-type 'int32))
         (xs0 (make-array n :fill-pointer 0 :element-type 'int32))
         (xs+ (make-array n :fill-pointer 0 :element-type 'int32))
         (ys- (make-array n :fill-pointer 0 :element-type 'int32))
         (ys0 (make-array n :fill-pointer 0 :element-type 'int32))
         (ys+ (make-array n :fill-pointer 0 :element-type 'int32)))
    (dotimes (i n)
      (let ((x (read-fixnum))
            (y (read-fixnum))
            (d (read-char)))
        (ecase d
          (#\R
           (vector-push-extend x xs+)
           (vector-push-extend y ys0))
          (#\L
           (vector-push-extend x xs-)
           (vector-push-extend y ys0))
          (#\U
           (vector-push-extend x xs0)
           (vector-push-extend y ys+))
          (#\D
           (vector-push-extend x xs0)
           (vector-push-extend y ys-)))))
    (let ((xmax+ (reduce #'max xs+ :initial-value most-negative-fixnum))
          (xmax- (reduce #'max xs- :initial-value most-negative-fixnum))
          (xmax0 (reduce #'max xs0 :initial-value most-negative-fixnum))
          (ymax+ (reduce #'max ys+ :initial-value most-negative-fixnum))
          (ymax- (reduce #'max ys- :initial-value most-negative-fixnum))
          (ymax0 (reduce #'max ys0 :initial-value most-negative-fixnum))
          (xmin+ (reduce #'min xs+ :initial-value most-positive-fixnum))
          (xmin- (reduce #'min xs- :initial-value most-positive-fixnum))
          (xmin0 (reduce #'min xs0 :initial-value most-positive-fixnum))
          (ymin+ (reduce #'min ys+ :initial-value most-positive-fixnum))
          (ymin- (reduce #'min ys- :initial-value most-positive-fixnum))
          (ymin0 (reduce #'min ys0 :initial-value most-positive-fixnum)))
      (let ((cands (list (* 0.5d0 (- xmax- xmax+))
                         (* 0.5d0 (- xmin- xmin+))
                         (* 0.5d0 (- ymax- ymax+))
                         (* 0.5d0 (- ymin- ymin+))
                         (- xmax- xmax0)
                         (- xmax0 xmax+)
                         (- xmin- xmin0)
                         (- xmin0 xmin+)
                         (- ymax- ymax0)
                         (- ymax0 ymax+)
                         (- ymin- ymin0)
                         (- ymin0 ymin+))))
        (println
         (loop for time in cands
               minimize
                  (let ((time (float time 1d0)))
                    (* (- (max (- xmax- time) (+ xmax+ time) xmax0)
                          (min (- xmin- time) (+ xmin+ time) xmin0))
                       (- (max (- ymax- time) (+ ymax+ time) ymax0)
                          (min (- ymin- time) (+ ymin+ time) ymin0))))))))))

#-swank(main)