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: Accepted)

#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int n;
pair<vector<double>, vi> range(vi x, vector<char> d, char right, char left) {
  int max_right = -inf, max_left = -inf, max_const = -inf;
  vi idx(3, -1);
  rep (i, n) {
    if (d[i] == right) {
      if (max_right < x[i]) {
        max_right = x[i];
        idx[0] = i;
      }
    }
    else if (d[i] == left) {
      if (max_left < x[i]) {
        max_left = x[i];
        idx[1] = i;
      }
    }
    else {
      if (max_const < x[i]) {
        max_const = x[i];
        idx[2] = i;
      }
    }
  }

  vector<double> time;
  if (idx[0] != -1 and idx[1] != -1) {
    time.push_back(abs(x[idx[1]] - x[idx[0]]) / 2.);
  }
  if (idx[0] != -1 and idx[2] != -1) {
    time.push_back(abs(x[idx[2]] - x[idx[0]]));
  }
  if (idx[1] != -1 and idx[2] != -1) {
    time.push_back(abs(x[idx[1]] - x[idx[2]]));
  }
  rep (i, 3) {
    if (idx[i] == -1) idx[i] = 0;
  }
  return make_pair(time, idx);
}

vi x, y;
vector<char> d;

double f(double t, vi &idx) {
  double xmi = INF, xma = -INF, ymi = INF, yma = -INF;
  for (int i: idx) {
    double xx, yy;
    if (d[i] == 'U') {
      xx = x[i];
      yy = y[i] + t;
    }
    else if (d[i] == 'D') {
      xx = x[i];
      yy = y[i] - t;
    }
    else if (d[i] == 'R') {
      xx = x[i] + t;
      yy = y[i];
    }
    else if (d[i] == 'L') {
      xx = x[i] - t;
      yy = y[i];
    }
    chmin(xmi, xx);
    chmin(ymi, yy);
    chmax(xma, xx);
    chmax(yma, yy);
  }
  //DEBUG(t);
  //DEBUG(make_pair(make_pair(xmi, xma), make_pair(ymi, yma)));
  return (xma - xmi) * (yma - ymi);
}

double solve(double l, double r, vi idx) {
  double ans = min(f(l, idx), f(r, idx));
  rep (_, 200) {
    //DEBUG(make_pair(l, r));
    double t1 = (2*l + r) / 3., t2 = (l + 2 * r) / 3.;
    double s1 = f(t1, idx), s2 = f(t2, idx);
    if (s1 < s2) {
      r = t2;
    }
    else {
      l = t1;
    }
  }
  return min(ans, f(l, idx));
}

signed main() {
  fio();
  cin >> n;
  x.resize(n);
  y.resize(n);
  d.resize(n);

  rep (i, n) {
    cin >> x[i] >> y[i] >> d[i];
  }

  vector<double> time;
  vi idx;
  auto temp = range(x, d, 'R', 'L');
  time.insert(time.end(), temp.first.begin(), temp.first.end());
  idx.insert(idx.end(), temp.second.begin(), temp.second.end());
  temp = range(y, d, 'U', 'D');
  time.insert(time.end(), temp.first.begin(), temp.first.end());
  idx.insert(idx.end(), temp.second.begin(), temp.second.end());
  rep (i, n) {
    x[i] *= -1;
    y[i] *= -1;
  }
  temp = range(x, d, 'L', 'R');
  time.insert(time.end(), temp.first.begin(), temp.first.end());
  idx.insert(idx.end(), temp.second.begin(), temp.second.end());
  temp = range(y, d, 'D', 'U');
  time.insert(time.end(), temp.first.begin(), temp.first.end());
  idx.insert(idx.end(), temp.second.begin(), temp.second.end());
  rep (i, n) {
    x[i] *= -1;
    y[i] *= -1;
  }

  time.push_back(0);
  time.push_back(inf);
  sort(all(time));
  UNIQUE(time);
  reverse(all(time));
  while (time.back() < 0) {
    time.pop_back();
  }
  reverse(all(time));

  sort(all(idx));
  UNIQUE(idx);
  //DEBUG_VEC(time);
  //DEBUG_VEC(idx);
  double ans = INF;
  rep (i, time.size() - 1) {
    chmin(ans, f(time[i], idx));
    //chmin(ans, solve(time[i], time[i + 1], idx));
  }
  Sp(ans);
}