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.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
static long test = 0;//二部探索回数のメモ
static int n = int.Parse(Console.ReadLine());
static long[] xmin = new long[3];
static long[] xmax = new long[3];
static long[] ymin = new long[3];
static long[] ymax = new long[3];

	static void Main()
	{
    double answer = double.MaxValue;
    double[] answerTime = new double[3];

    for(int i = 0; i < 3; i++)
    {
      xmin[i] = long.MaxValue/2;
      xmax[i] = long.MinValue/2;
      ymin[i] = long.MaxValue/2;
      ymax[i] = long.MinValue/2;
    }
    
    for(long i = 0; i < n; i++)
    {
      string[] nums = Console.ReadLine().Split(' ');
      if(nums[2] == "U")
      {
        xmin[0] = Math.Min(xmin[0], long.Parse(nums[0]));
        xmax[0] = Math.Max(xmax[0], long.Parse(nums[0]));
        ymin[2] = Math.Min(ymin[2], long.Parse(nums[1]));
        ymax[2] = Math.Max(ymax[2], long.Parse(nums[1]));
      }
      if(nums[2] == "D")
      {
        xmin[0] = Math.Min(xmin[0], long.Parse(nums[0]));
        xmax[0] = Math.Max(xmax[0], long.Parse(nums[0]));
        ymin[1] = Math.Min(ymin[1], long.Parse(nums[1]));
        ymax[1] = Math.Max(ymax[1], long.Parse(nums[1]));
      }
      if(nums[2] == "R")
      {
        xmin[2] = Math.Min(xmin[2], long.Parse(nums[0]));
        xmax[2] = Math.Max(xmax[2], long.Parse(nums[0]));
        ymin[0] = Math.Min(ymin[0], long.Parse(nums[1]));
        ymax[0] = Math.Max(ymax[0], long.Parse(nums[1]));
      }
      if(nums[2] == "L")
      {
        xmin[1] = Math.Min(xmin[1], long.Parse(nums[0]));
        xmax[1] = Math.Max(xmax[1], long.Parse(nums[0]));
        ymin[0] = Math.Min(ymin[0], long.Parse(nums[1]));
        ymax[0] = Math.Max(ymax[0], long.Parse(nums[1]));
      }
    }

    answerTime[0] = Search(0, 99999999d);
    answer = Answer(answerTime[0]);
    
    answerTime[1] = Searchb(0,Math.Max(0,answerTime[0]-0.00001));
    answerTime[2] = Search(answerTime[0]+0.00001,999999999d);

    answer = Math.Min(answer, Answer(Searchb(0,Math.Max(0,answerTime[1]-0.00001))));
    answer = Math.Min(answer, Answer(Search(answerTime[2]+0.00001,999999999d)));
    Console.WriteLine(answer);
	}

  static double Search(double min, double max)//二分探索法で最大値を求める
  {
    while (true)
    {
      test++;
      double mid = min + (max - min) / 2;
      if(Check(mid)) min = mid;//さらに大きくても成り立つかも
      else max = mid;

      if(test > 1000)//二分探索を1000回行ったら終了
      {
        if(Check(max)) 
        {
          return max;//最大値で成り立つかの確認を優先
        }
        else
        {
          return min;
        }
      break;
      }  
    }
  }

  static bool Check(double testNum)
  {
    if(Answer(testNum+(double)0.00000000001) - Answer(testNum) < 0
      && Answer(testNum-(double)0.00000000001) - Answer(testNum) > 0) return true;
    return false;
  }

  static double Searchb(double min, double max)//二分探索法で最大値を求める
  {
    while (true)
    {
      test++;
      double mid = min + (max - min) / 2;
      if(Checkb(mid)) max = mid;//さらに大きくても成り立つかも
      else min = mid;

      if(test > 10000)//二分探索を10000回行ったら終了
      {
        if(Checkb(max)) 
        {
          return min;//最大値で成り立つかの確認を優先
        }
        else
        {
          return max;
        }
      break;
      }  
    }
  }

  static bool Checkb(double testNum)
  {
    if(Answer(testNum+(double)0.00000000001) - Answer(testNum) > 0
      && Answer(testNum-(double)0.00000000001) - Answer(testNum) < 0) return true;
    return false;
  }

  static double Answer(double time)
  {
    double xxmin = Math.Min(xmin[0],(double)xmin[1]-time);
    xxmin = Math.Min(xxmin,(double)xmin[2]+time);
    double xxmax = Math.Max(xmax[0],(double)xmax[1]-time);
    xxmax = Math.Max(xxmax,(double)xmax[2]+time);
    
    double yymin = Math.Min(ymin[0],(double)ymin[1]-time);
    yymin = Math.Min(yymin,(double)ymin[2]+time);
    double yymax = Math.Max(ymax[0],(double)ymax[1]-time);
    yymax = Math.Max(yymax,(double)ymax[2]+time);

    double answer = (xxmax-xxmin)*(yymax-yymin);
    return answer;
  }
  
}