Language: C++

#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int64_t i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int64_t i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int64_t i = beg; end <= i; i--)

using namespace std;

enum Dir {
	kR,
	kL,
	kU,
	kD
};

struct Point {
	int64_t x;
	int64_t y;
	Dir d;
};

pair<bool, int64_t> intersect(int64_t add, int64_t sub) {
	if (sub < add) return { false, 0 };
	else return { true, (sub - add) / 2 };
}

void add_cand(int64_t add, int64_t sub, set<int64_t> & cand) {
	auto ret = intersect(add, sub);
	if (ret.first) cand.insert(ret.second);
}

void add_cand_a(int64_t add, int64_t cons, set<int64_t>& cand) {
	if (cons < add) return;
	cand.insert(cons - add);
}

void add_cand_d(int64_t sub, int64_t cons, set<int64_t>& cand) {
	if (sub < cons) return;
	cand.insert(sub - cons);
}

double evaluate(vector<Point> & ps, double t) {
	double xmax = INT_MIN, xmin = INT_MAX;
	double ymax = INT_MIN, ymin = INT_MAX;

	for (auto& p : ps) {
		if (p.d == kU || p.d == kD) {
			xmax = max(xmax, (double)p.x);
			xmin = min(xmin, (double)p.x);

			double y = 0;
			if (p.d == kU) {
				y = p.y + t;
			}
			else {
				y = p.y - t;
			}
			ymax = max(ymax, y);
			ymin = min(ymin, y);
		}
		else {
			ymax = max(ymax, (double) p.y);
			ymin = min(ymin, (double) p.y);

			double x = 0;
			if (p.d == kR) {
				x = p.x + t;
			}
			else {
				x = p.x - t;
			}
			xmax = max(xmax, (double) x);
			xmin = min(xmin, (double) x);
		}
	}

	return (xmax - xmin) * (ymax - ymin);
}

double trisearch(vector<Point>& ps, double first, double last)
{
	double first_third  = evaluate(ps, (first) + (last - first) / 3);
	double second_third = evaluate(ps, (first) + (last - first) * 2 / 3);

	if (abs(first_third - second_third) < 0.0000000001) return first_third;

	if (second_third > first_third) {
		return trisearch(ps, first, (first) + (last - first) * 2/ 3);
	}
	else {
		return trisearch(ps, (first) + (last - first) / 3, last);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int64_t n; cin >> n;

	vector<Point> ps(n);
	for (auto& p : ps) {
		cin >> p.x >> p.y;
		p.x *= 2; p.y *= 2;
		char c; cin >> c;
		if (c == 'R') p.d = kR;
		if (c == 'L') p.d = kL;
		if (c == 'U') p.d = kU;
		if (c == 'D') p.d = kD;
	}

	int64_t x_th_max = INT_MIN, x_th_min = INT_MAX, y_th_max = INT_MIN, y_th_min = INT_MAX;
	for (auto& p : ps) {
		if (p.d == kU || p.d == kD) {
			x_th_max = max(x_th_max, p.x);
			x_th_min = min(x_th_min, p.x);
		}
		else {
			y_th_max = max(y_th_max, p.y);
			y_th_min = min(y_th_min, p.y);
		}
	}

	int64_t rightmax = INT_MIN, rightmin = INT_MAX, leftmax = INT_MIN, leftmin = INT_MAX;
	int64_t upmax = INT_MIN, upmin = INT_MAX, downmax = INT_MIN, downmin = INT_MAX;
	bool has_right = false, has_left = false, has_up = false, has_down = false;
	for (auto& p : ps) {
		if (p.d == kR) {
			has_right = true;
			rightmax = max(rightmax, p.x);
			rightmin = min(rightmin, p.x);
		}
		if (p.d == kL) {
			has_left = true;
			leftmax = max(leftmax, p.x);
			leftmin = min(leftmin, p.x);
		}
		if (p.d == kU) {
			has_up = true;
			upmax = max(upmax, p.y);
			upmin = min(upmin, p.y);
		}
		if (p.d == kD) {
			has_down = true;
			downmax = max(downmax, p.y);
			downmin = min(downmin, p.y);
		}
	}

	set<int64_t> cand;
	if (has_right && has_left) {
		add_cand(rightmax, leftmax, cand);
		add_cand(rightmax, leftmin, cand);
		add_cand(rightmin, leftmax, cand);
		add_cand(rightmin, leftmin, cand);
	}
	if (has_right) {
		add_cand_a(rightmax, x_th_max, cand);
		add_cand_a(rightmin, x_th_max, cand);
		add_cand_a(rightmax, x_th_min, cand);
		add_cand_a(rightmin, x_th_min, cand);
	}
	if (has_left) {
		add_cand_d(leftmax, x_th_max, cand);
		add_cand_d(leftmin, x_th_max, cand);
		add_cand_d(leftmax, x_th_min, cand);
		add_cand_d(leftmin, x_th_min, cand);
	}

	if (has_up && has_down) {
		add_cand(upmax, downmax, cand);
		add_cand(upmax, downmin, cand);
		add_cand(upmin, downmax, cand);
		add_cand(upmin, downmin, cand);
	}
	if (has_up) {
		add_cand_a(upmax, y_th_max, cand);
		add_cand_a(upmin, y_th_max, cand);
		add_cand_a(upmax, y_th_min, cand);
		add_cand_a(upmin, y_th_min, cand);
	}
	if (has_down) {
		add_cand_d(downmax, y_th_max, cand);
		add_cand_d(downmin, y_th_max, cand);
		add_cand_d(downmax, y_th_min, cand);
		add_cand_d(downmin, y_th_min, cand);
	}
	cand.insert(0);

	double min_val = DBL_MAX;
	auto first = cand.begin();
	auto last  = first; last++;

	while (last != cand.end()) {
		min_val = min(min_val, trisearch(ps, *first, *last));
		first = last;
		last++;
	}

	cout << min_val / 4.0 << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:213:26: error: 'DBL_MAX' was not declared in this scope
  213 |         double min_val = DBL_MAX;
      |                          ^~~~~~~
a.cc:24:1: note: 'DBL_MAX' is defined in header '<cfloat>'; this is probably fixable by adding '#include <cfloat>'
   23 | #include <functional>
  +++ |+#include <cfloat>
   24 |