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 Rust (1.15.1) (judge verdict: Accepted)

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn calc_area(t: f64, seq: &Vec<(f64, f64, usize)>) -> f64 {
    let n = seq.len();
    let mut max_x = -1e+9;
    let mut max_y = -1e+9;
    let mut min_x = 1e+9;
    let mut min_y = 1e+9;
    for i in 0..n {
        let dx = [1.0, -1.0, 0.0, 0.0][seq[i].2];
        let dy = [0.0, 0.0, 1.0, -1.0][seq[i].2];
        let x = seq[i].0 + dx * t;
        let y = seq[i].1 + dy * t;
        max_x = f64::max(max_x, x);
        max_y = f64::max(max_y, y);
        min_x = f64::min(min_x, x);
        min_y = f64::min(min_y, y);
    }
    return (max_x - min_x) * (max_y - min_y);
}

fn find_cross_ts(seq: &Vec<(f64, f64, usize)>) -> Vec<f64> {
    let n = seq.len();
    let mut max_xs = vec![-1e+9, -1e+9, -1e+9];
    let mut min_xs = vec![1e+9, 1e+9, 1e+9];
    for i in 0..n {
        let mut d = seq[i].2;
        if d == 3 {
            d = 2;
        }
        let x = seq[i].0;
        max_xs[d] = f64::max(max_xs[d], x);
        min_xs[d] = f64::min(min_xs[d], x);
    }
    let mut ret = vec![];
    ret.push((max_xs[0] - max_xs[1]).abs() / 2.0);
    ret.push((min_xs[0] - min_xs[1]).abs() / 2.0);
    ret.push((max_xs[0] - max_xs[2]).abs());
    ret.push((min_xs[0] - min_xs[2]).abs());
    ret.push((max_xs[1] - max_xs[2]).abs());
    ret.push((min_xs[1] - min_xs[2]).abs());
    return ret;
}

fn main() {
    let n = read::<usize>();
    let mut seq = vec![(0.0, 0.0, 0); n];
    for i in 0..n {
        seq[i].0 = read::<f64>();
        seq[i].1 = read::<f64>();
        let d = read::<String>().chars().collect::<Vec<char>>()[0];
        seq[i].2 = match d {
            'R' => 0,
            'L' => 1,
            'U' => 2,
            'D' => 3,
            _ => unimplemented!(),
        }
    }
    let mut ans = calc_area(0.0, &seq);
    for _iter in 0..2 {
        let candidate = find_cross_ts(&seq);
        for &t in candidate.iter() {
            ans = f64::min(ans, calc_area(t, &seq));
        }
        // x, y swap
        for i in 0..n {
            let t = seq[i].0;
            seq[i].0 = seq[i].1;
            seq[i].1 = t;
            seq[i].2 ^= 2;
        }
    }
    println!("{:.10}", ans);
}