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# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static double[][] h;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Arr(n,(x)=>new Tuple<int,int,char>(int.Parse(x[0]),int.Parse(x[1]),x[2].ToCharArray()[0]));
		h=new double[][]{
			new double[]{int.MaxValue,int.MinValue},
			new double[]{int.MaxValue,int.MinValue},
			new double[]{int.MaxValue,int.MinValue},
			new double[]{int.MaxValue,int.MinValue},
			new double[]{int.MaxValue,int.MinValue},
			new double[]{int.MaxValue,int.MinValue}
		};
		for(int i = 0;i<n;i++) {
			if(a[i].Item3=='U'){
				h[0][0]=Min(h[0][0],a[i].Item2);
				h[0][1]=Max(h[0][1],a[i].Item2);
				h[5][0]=Min(h[5][0],a[i].Item1);
				h[5][1]=Max(h[5][1],a[i].Item1);
			}
			else if(a[i].Item3=='D'){
				h[1][0]=Min(h[1][0],a[i].Item2);
				h[1][1]=Max(h[1][1],a[i].Item2);
				h[5][0]=Min(h[5][0],a[i].Item1);
				h[5][1]=Max(h[5][1],a[i].Item1);
			}
			else if(a[i].Item3=='L'){
				h[2][0]=Min(h[2][0],a[i].Item1);
				h[2][1]=Max(h[2][1],a[i].Item1);
				h[4][0]=Min(h[4][0],a[i].Item2);
				h[4][1]=Max(h[4][1],a[i].Item2);
			}
			else{
				h[3][0]=Min(h[3][0],a[i].Item1);
				h[3][1]=Max(h[3][1],a[i].Item1);
				h[4][0]=Min(h[4][0],a[i].Item2);
				h[4][1]=Max(h[4][1],a[i].Item2);
			}
		}
		Console.WriteLine("{0}",Tst(0,1000000000));
	}
	static double Tst(double a,double b){
		DateTime st=DateTime.Now;
		double lb=a,ub=b,c1=0,c2=0,d1=0,d2=0;
		while(ub-lb>1e-9&&(DateTime.Now-st).TotalMilliseconds<4800){
			c1=(lb*2+ub)/3;
			c2=(lb+ub*2)/3;
			d1=Fu(c1);
			d2=Fu(c2);
			if(d1>d2){lb=c1;}
			else{ub=c2;}
		}
		return d1;
	}
	static double Fu(double i){
		return (Max(Max(h[0][1]+i,h[1][1]-i),h[4][1])-Min(Min(h[0][0]+i,h[1][0]-i),h[4][0]))*(Max(Max(h[2][1]-i,h[3][1]+i),h[5][1])-Min(Min(h[2][0]-i,h[3][0]+i),h[5][0]));
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2(int b){return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}
	public int[] Ia3(int a,int b){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(int a,int b,int c,int d){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()+(c!=0?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2(int b){return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}
	public long[] La3(int a,int b){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(int a,int b,int c,int d){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()+(c!=0?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}