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)

#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

using vd = vector<double>;
const double inf = 1e10;
struct D{
  vd left, right; // 速度 0,1,2
  D():left(3,inf),right(3,-inf){}
  void add(int i, double p){
    chmin(left[i],p);
    chmax(right[i],p);
  }
  double get(double t){
    double mmax = -inf, mmin = inf;
    rep(i,3) chmin(mmin, left[i]+t*double(i));
    rep(i,3) chmax(mmax, right[i]+t*double(i));
    return mmax - mmin;
  }
  vd enmr(){
    vd res;
    rep(i,2) REP(j,i+1,3){
      double t = (left[i]-left[j])/double(j-i); // left[i]+i*t==left[j]+i*t
      if(t<0) continue;
      res.pb(t);
    } 
    rep(i,2) REP(j,i+1,3){
      double t = (right[i]-right[j])/double(j-i); // right[i]+i*t==right[j]+i*t
      if(t<0) continue;
      res.pb(t);
    }
    return res;
  }
};

void solve(long long N, std::vector<long long> x, std::vector<long long> y, std::vector<std::string> d){
  D dx,dy;
  rep(i,N){
    char c = d[i][0];
    if(c=='R') dx.add(2,x[i]), dy.add(1,y[i]);
    if(c=='L') dx.add(0,x[i]), dy.add(1,y[i]);
    if(c=='U') dx.add(1,x[i]), dy.add(2,y[i]);
    if(c=='D') dx.add(1,x[i]), dy.add(0,y[i]);
  }
  vd cand; // 端点候補
  cand.pb(0); cand.pb(inf);
  {
    auto vec = dx.enmr();
    cand.insert(cand.end(),vec.begin(),vec.end());
  }
  {
    auto vec = dy.enmr();
    cand.insert(cand.end(),vec.begin(),vec.end());
  }
  sort(ALL(cand));
  double ans = 1e18;
  for(auto t:cand){
    double val = dx.get(t) * dy.get(t);
    chmin(ans, val);
  }
  cout << setprecision(10);
  cout << ans << endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> x(N);
  std::vector<long long> y(N);
  std::vector<std::string> d(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&x[i]);
    scanf("%lld",&y[i]);
    std::cin >> d[i];
  }
  solve(N, std::move(x), std::move(y), std::move(d));
  return 0;
}