Language: C++

#include <bits/stdc++.h>
#include <limits>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
typedef long long ll;
typedef long double lf;
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
#define LAR(a, b) ((a)=max((a), (b)))
#define SML(a, b) ((a)=min((a), (b)))
#define EB emplace_back
#define PB push_back
#define MP make_pair

typedef pair<ll, ll> pll;
#define N 112345
ll x[N], y[N];
char d[N];
char e[5]="LRDU";
ll mi[3], mx[3];
vector<pll> s[2];
vector<ll> u;
vector<pll> v;
vector<pair<ll, pll>> w[2];
char sstt[2];
vector<ll> z;

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%lld%lld%s", x+i, y+i, sstt), d[i]=*sstt;
	REP(i, n) x[i]*=2, y[i]*=2;
	REP(ii, 2){
		REP(j, 3) mi[j]=LLONG_MAX, mx[j]=LLONG_MIN;
		REP(i, n) {
			int f;
			if(d[i]==e[ii*2+0]) f=0;
			else if(d[i]==e[ii*2+1]) f=2;
			else f=1;
			ll xy = ii==0 ? x[i] : y[i];
			SML(mi[f], xy);
			LAR(mx[f], xy);
		}
		DEBUG("%lld %lld %lld\n", mx[0], mx[1], mx[2]);
		DEBUG("%lld %lld %lld\n", mi[0], mi[1], mi[2]);
		s[0].clear(); s[1].clear();
		REP(j, 3){
			if(mi[j]==LLONG_MAX) continue;
			s[0].EB(j-1, mi[j]);
			s[1].EB(j-1, mx[j]);
		}
		u.clear();
		u.EB(0);
		for(auto &ss : s){
			REP(j, (int)ss.size()){
				FOR(k, j+1, (int)ss.size()){
					u.EB( - (ss[j].second - ss[k].second) / (ss[j].first - ss[k].first) );
				}
			}
		}
		sort(u.begin(), u.end());
		for(auto it = lower_bound(u.begin(), u.end(), 0); it != u.end(); it++){
			ll t = *it;
			ll a = 0, b = 0;
			REP(l, 2){
				v.clear();
				for(pll &p : s[l]){
					v.EB( p.first * t + p.second , p.first );
				}
				if(l==0) sort(v.begin(), v.end(), less<pll>());
				if(l==1) sort(v.begin(), v.end(), greater<pll>());
				a += v[0].second;
				b += v[0].first - v[0].second * t;
				// DEBUG("     %lldt%+lld\n", v[0].second, v[0].first - v[0].second * t);
				if(l) break;
				a *= -1;
				b *= -1;
			}
			DEBUG("%lld~ f(t)=%lldt%+lld\n", t, a, b);
			w[ii].EB(t, MP(a, b));
			z.EB(t);
		}
		for(int i=w[ii].size()-1; i>=0; i--){
			if(w[ii][i].first == w[ii][i+1].first){
				w[ii][i].second = w[ii][i+1].second;
			}
		}
	}
	sort(z.begin(), z.end());
	z.EB(LLONG_MAX);
	int i=0, j=0;
	lf ans = infinity();
	REP(k, (int)z.size()-1){
		lf t = z[k], u = z[k+1];
		while(i+1 < (int)w[0].size() && w[0][i+1].first <= t) i++;
		while(j+1 < (int)w[1].size() && w[1][j+1].first <= t) j++;
		pll &d = w[0][i].second, &e = w[1][j].second;
		DEBUG("%.0Lf~%.0Lf f(t)=(%lldt%+lld)(%lldt%+lld)\n", t, u, d.first, d.second, e.first, e.second);
		ll a = d.first  * e.first,
			 b = d.first  * e.second * 
				   d.second * e.first;
		SML(ans, (t * d.first + d.second) * (t * e.first + e.second) );
		DEBUG("   Left: %.2Lf\n", (t * d.first + d.second) * (t * e.first + e.second) );
		if(a != 0){
			lf v = b / 2.0L / a;
			if(t <= v && (u==LLONG_MAX || v <= u)){
				SML(ans, (v * d.first + d.second) * (v * e.first + e.second) );
				DEBUG("   Local minima at t=%.10Lf: %.10Lf\n", v, (v * d.first + d.second) * (v * e.first + e.second));
			}
		}
	}
	printf("%.30Lf\n", ans/4);
}




Compiler output:
a.cc: In function 'int main()':
a.cc:95:18: error: 'infinity' was not declared in this scope; did you mean 'finite'?
   95 |         lf ans = infinity();
      |                  ^~~~~~~~
      |                  finite