atcoder#ABC130F. [ABC130F] Minimum Bounding Box

[ABC130F] Minimum Bounding Box

Score : 600600 points

Problem Statement

There are NN points in a two-dimensional plane. The initial coordinates of the ii-th point are (xi,yi)(x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the xx- or yy- axis. You are given a character did_i that represents the specific direction in which the ii-th point moves, as follows:

  • If di=d_i = R, the ii-th point moves in the positive xx direction;
  • If di=d_i = L, the ii-th point moves in the negative xx direction;
  • If di=d_i = U, the ii-th point moves in the positive yy direction;
  • If di=d_i = D, the ii-th point moves in the negative yy 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 xmaxx_{max} and xminx_{min} be the maximum and minimum among the xx-coordinates of the NN points, respectively. Similarly, let ymaxy_{max} and yminy_{min} be the maximum and minimum among the yy-coordinates of the NN points, respectively.

Find the minimum possible value of (xmaxxmin)×(ymaxymin)(x_{max} - x_{min}) \times (y_{max} - y_{min}) and print it.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 108xi, yi108-10^8 \leq x_i,\ y_i \leq 10^8
  • xix_i and yiy_i are integers.
  • did_i is R, L, U, or D.

Input

Input is given from Standard Input in the following format:

NN

x1x_1 y1y_1 d1d_1

x2x_2 y2y_2 d2d_2

..

..

..

xNx_N yNy_N dNd_N

Output

Print the minimum possible value of (xmaxxmin)×(ymaxymin)(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 10910^{-9}.

2
0 3 D
3 0 L
0

After three seconds, the two points will meet at the origin. The value in question will be 00 at that moment.

5
-7 -10 U
7 -6 U
-8 7 D
-3 3 D
0 -6 R
97.5

The answer may not be an integer.

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
273