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 C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

#define LEFT 0
#define RIGHT 1
#define UP 2
#define DOWN 3

const int MAX_RANGE = 5e8;

int N;
ll lmn, rmx, tmn, bmx;
ll direction[4][2];

ll calc(ll mn, ll mx, int i1, int i2, ll t) {
    ll r = mx, l = mn;
    if (direction[i1][1] != MAX_RANGE) {
        r = max(r, direction[i1][1]-t);
        l = min(l, direction[i1][0]-t);
    }
    if (direction[i2][1] != MAX_RANGE) {
        r = max(r, direction[i2][1]+t);
        l = min(l, direction[i2][0]+t);
    }
    return r-l;
}

ll calcArea(ll t) {
    ll c = calc(lmn, rmx, LEFT, RIGHT, t) * calc(tmn, bmx, DOWN, UP, t);
    return c;
}

ll solve_sub(ll mn, ll mx, int i1, int i2) {
    ll lo = -1, hi = MAX_RANGE;
    while (hi - lo > 2) {
        ll m1 = (hi+2*lo)/3;
        ll m2 = (2*hi+lo)/3;
        ll a = calc(mn, mx, i1, i2, m1);
        ll b = calc(mn, mx, i1, i2, m2);
        if (a > b) lo = m1;
        else hi = m2;
    }
    ll minValue = 1e18;
    ll minTime = -1;
    FOR (i, lo, hi+1) if (i >= 0) {
        ll v = calc(mn, mx, i1, i2, i);
        if (v < minValue) {
            minValue = v;
            minTime = i;
        }
    }

    // 最小になる瞬間
    lo = -1, hi = minTime;
    while (hi - lo > 1) {
        ll mid = (hi+lo)/2;
        if (calc(mn, mx, i1, i2, mid) == minValue) hi = mid;
        else lo = mid;
    }
    ll ans = calcArea(hi);

    // 最小が終わる瞬間
    lo = minTime, hi = MAX_RANGE;
    while (hi - lo > 1) {
        ll mid = (hi+lo)/2;
        if (calc(mn, mx, i1, i2, mid) == minValue) lo = mid;
        else hi = mid;
    }
    return min(ans, calcArea(lo));
}

long double solve() {
    return 
        min(calcArea(0), 
            min(solve_sub(lmn, rmx, LEFT, RIGHT),
                solve_sub(tmn, bmx, DOWN, UP)))/4.0;
}

int main() {
    cin >> N;
    lmn = tmn = MAX_RANGE;
    rmx = bmx = -MAX_RANGE;
    REP (i, 4) {
        direction[i][0] = MAX_RANGE;
        direction[i][1] = -MAX_RANGE;
    }
    REP (i, N) {
        ll x, y; char d;
        cin >> x >> y >> d;
        x *= 2;
        y *= 2;
        if (d == 'R') {
            tmn = min(tmn, y);
            bmx = max(bmx, y);
            direction[RIGHT][0] = min(direction[RIGHT][0], x);
            direction[RIGHT][1] = max(direction[RIGHT][1], x);
        } else if (d == 'L') {
            tmn = min(tmn, y);
            bmx = max(bmx, y);
            direction[LEFT][0] = min(direction[LEFT][0], x);
            direction[LEFT][1] = max(direction[LEFT][1], x);
        } else if (d == 'U') {
            lmn = min(lmn, x);
            rmx = max(rmx, x);
            direction[UP][0] = min(direction[UP][0], y);
            direction[UP][1] = max(direction[UP][1], y);
        } else if (d == 'D') {
            lmn = min(lmn, x);
            rmx = max(rmx, x);
            direction[DOWN][0] = min(direction[DOWN][0], y);
            direction[DOWN][1] = max(direction[DOWN][1], y);
        }
    }
    cout << setprecision(12) << solve() << endl;
}