提出 #63621537


ソースコード 拡げる

#ifndef HIDDEN_IN_VS // 折りたたみ用

// 警告の抑制
#define _CRT_SECURE_NO_WARNINGS

// ライブラリの読み込み
#include <bits/stdc++.h>
using namespace std;

// 型名の短縮
using ll = long long; using ull = unsigned long long; // -2^63 ~ 2^63 = 9e18(int は -2^31 ~ 2^31 = 2e9)
using pii = pair<int, int>;	using pll = pair<ll, ll>;	using pil = pair<int, ll>;	using pli = pair<ll, int>;
using vi = vector<int>;		using vvi = vector<vi>;		using vvvi = vector<vvi>;	using vvvvi = vector<vvvi>;
using vl = vector<ll>;		using vvl = vector<vl>;		using vvvl = vector<vvl>;	using vvvvl = vector<vvvl>;
using vb = vector<bool>;	using vvb = vector<vb>;		using vvvb = vector<vvb>;
using vc = vector<char>;	using vvc = vector<vc>;		using vvvc = vector<vvc>;
using vd = vector<double>;	using vvd = vector<vd>;		using vvvd = vector<vvd>;
template <class T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
using Graph = vvi;

// 定数の定義
const double PI = acos(-1);
int DX[4] = { 1, 0, -1, 0 }; // 4 近傍(下,右,上,左)
int DY[4] = { 0, 1, 0, -1 };
int INF = 1001001001; ll INFL = 4004004003094073385LL; // (int)INFL = INF, (int)(-INFL) = -INF;

// 入出力高速化
struct fast_io { fast_io() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(18); } } fastIOtmp;

// 汎用マクロの定義
#define all(a) (a).begin(), (a).end()
#define sz(x) ((int)(x).size())
#define lbpos(a, x) (int)distance((a).begin(), std::lower_bound(all(a), (x)))
#define ubpos(a, x) (int)distance((a).begin(), std::upper_bound(all(a), (x)))
#define Yes(b) {cout << ((b) ? "Yes\n" : "No\n");}
#define rep(i, n) for(int i = 0, i##_len = int(n); i < i##_len; ++i) // 0 から n-1 まで昇順
#define repi(i, s, t) for(int i = int(s), i##_end = int(t); i <= i##_end; ++i) // s から t まで昇順
#define repir(i, s, t) for(int i = int(s), i##_end = int(t); i >= i##_end; --i) // s から t まで降順
#define repe(v, a) for(const auto& v : (a)) // a の全要素(変更不可能)
#define repea(v, a) for(auto& v : (a)) // a の全要素(変更可能)
#define repb(set, d) for(int set = 0, set##_ub = 1 << int(d); set < set##_ub; ++set) // d ビット全探索(昇順)
#define repis(i, set) for(int i = lsb(set), bset##i = set; i < 32; bset##i -= 1 << i, i = lsb(bset##i)) // set の全要素(昇順)
#define repp(a) sort(all(a)); for(bool a##_perm = true; a##_perm; a##_perm = next_permutation(all(a))) // a の順列全て(昇順)
#define uniq(a) {sort(all(a)); (a).erase(unique(all(a)), (a).end());} // 重複除去
#define EXIT(a) {cout << (a) << endl; exit(0);} // 強制終了
#define inQ(x, y, u, l, d, r) ((u) <= (x) && (l) <= (y) && (x) < (d) && (y) < (r)) // 半開矩形内判定

// 汎用関数の定義
template <class T> inline ll powi(T n, int k) { ll v = 1; rep(i, k) v *= n; return v; }
template <class T> inline bool chmax(T& M, const T& x) { if (M < x) { M = x; return true; } return false; } // 最大値を更新(更新されたら true を返す)
template <class T> inline bool chmin(T& m, const T& x) { if (m > x) { m = x; return true; } return false; } // 最小値を更新(更新されたら true を返す)
template <class T> inline T getb(T set, int i) { return (set >> i) & T(1); }
template <class T> inline T smod(T n, T m) { n %= m; if (n < 0) n += m; return n; } // 非負mod

// 演算子オーバーロード
template <class T, class U> inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template <class T> inline istream& operator>>(istream& is, vector<T>& v) { repea(x, v) is >> x; return is; }
template <class T> inline vector<T>& operator--(vector<T>& v) { repea(x, v) --x; return v; }
template <class T> inline vector<T>& operator++(vector<T>& v) { repea(x, v) ++x; return v; }

#endif // 折りたたみ用


#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;

#ifdef _MSC_VER
#include "localACL.hpp"
#endif

using mint = modint998244353;
//using mint = static_modint<(ll)1e9+7>;
//using mint = modint; // mint::set_mod(m);

namespace atcoder {
	inline istream& operator>>(istream& is, mint& x) { ll x_; is >> x_; x = x_; return is; }
	inline ostream& operator<<(ostream& os, const mint& x) { os << x.val(); return os; }
}
using vm = vector<mint>; using vvm = vector<vm>; using vvvm = vector<vvm>; using vvvvm = vector<vvvm>; using pim = pair<int, mint>;
#endif


#ifdef _MSC_VER // 手元環境(Visual Studio)
#include "local.hpp"
#else // 提出用(gcc)
inline int popcount(int n) { return __builtin_popcount(n); }
inline int popcount(ll n) { return __builtin_popcountll(n); }
inline int lsb(int n) { return n != 0 ? __builtin_ctz(n) : 32; }
inline int lsb(ll n) { return n != 0 ? __builtin_ctzll(n) : 64; }
inline int msb(int n) { return n != 0 ? (31 - __builtin_clz(n)) : -1; }
inline int msb(ll n) { return n != 0 ? (63 - __builtin_clzll(n)) : -1; }
#define dump(...)
#define dumpel(v)
#define dump_math(v)
#define input_from_file(f)
#define output_to_file(f)
#define Assert(b) { if (!(b)) { vc MLE(1<<30); EXIT(MLE.back()); } } // RE の代わりに MLE を出す
#endif


//【ランダム三分探索(実数,最小値)】O(log((r - l) / EPS))
/*
* 全域で下に単峰な関数 f(x) の開区間 (l..r) における最小値を与える x を返す.
* 下に単峰じゃなくても運が良ければ正しい x を返す.
*/
template <class D, class FUNC>
pair<D, D> random_ternary_search_min(D l, D r, const FUNC& f, D EPS = 1e-12) {
	// verify : https://atcoder.jp/contests/abc130/tasks/abc130_f

	static bool first_call = true;

	static mt19937 mt;
	static uniform_real_distribution<D> rnd(0, 1);
	if (first_call) {
		mt.seed((int)time(NULL));
		first_call = false;
	}

	D m1 = l + (r - l) * rnd(mt);
	D f1 = f(m1);

	// 絶対誤差か相対誤差が EPS 以下になるまで
	while (r - l > EPS && r - l > EPS * abs(r + l) / 2) {
		D m2 = l + (r - l) * rnd(mt);
		D f2 = f(m2);

		if (m1 > m2) {
			swap(m1, m2);
			swap(f1, f2);
		}

		// 右の内分点での値の方が小さければ,次の区間は右側をとる.
		if (f1 > f2) {
			l = m1;
			m1 = m2;
			f1 = f2;
		}
		// 左の内分点での値の方が小さければ,次の区間は左側をとる.
		else {
			r = m2;
		}
	}

	return { m1, f1 };

	/* f の定義の雛形
	using D = double;
	auto f = [&](D x) {
		return (D)x;
	};
	auto [x, fx] = random_ternary_search_min<D>(l, r, f);
	*/
}


int main() {
//	input_from_file("input.txt");
//	output_to_file("output.txt");
	
	auto start = chrono::system_clock::now();

	int n;
	cin >> n;

	vi x(n), y(n); vc c(n);
	rep(i, n) cin >> x[i] >> y[i] >> c[i];

	int ln = INF, l0 = INF, lp = INF, rn = -INF, r0 = -INF, rp = -INF;
	int dn = INF, d0 = INF, dp = INF, un = -INF, u0 = -INF, up = -INF;

	rep(i, n) {
		if (c[i] == 'R') {
			chmin(lp, x[i]);
			chmax(rp, x[i]);
			chmin(d0, y[i]);
			chmax(u0, y[i]);
		}
		else if (c[i] == 'L') {
			chmin(ln, x[i]);
			chmax(rn, x[i]);
			chmin(d0, y[i]);
			chmax(u0, y[i]);
		}
		else if (c[i] == 'U') {
			chmin(l0, x[i]);
			chmax(r0, x[i]);
			chmin(dp, y[i]);
			chmax(up, y[i]);
		}
		else if (c[i] == 'D') {
			chmin(l0, x[i]);
			chmax(r0, x[i]);
			chmin(dn, y[i]);
			chmax(un, y[i]);
		}
	}

	auto f = [&](double t) {
		double l = min({ ln - t, l0 + 0., lp + t });
		double r = max({ rn - t, r0 + 0., rp + t });
		double d = min({ dn - t, d0 + 0., dp + t });
		double u = max({ un - t, u0 + 0., up + t });

		return (r - l) * (u - d);
	};

	double res = (double)INFL;

	// 凸関数の積なので双峰形だから,乱択で当たりを引けそう.
	while (true) {
		auto [t, ft] = random_ternary_search_min(0., (double)INFL, f);
		chmin(res, ft);

		auto now = chrono::system_clock::now();
		auto msec = chrono::duration_cast<std::chrono::milliseconds>(now - start).count();
		if (msec >= 1000) break;
	}

	cout << res << endl;
}

提出情報

提出日時
問題 F - Minimum Bounding Box
ユーザ ecottea
言語 C++ 20 (gcc 12.2)
得点 600
コード長 8178 Byte
結果 AC
実行時間 1001 ms
メモリ 4628 KiB

ジャッジ結果

セット名 All Sample
得点 / 配点 600 / 600 0 / 0
結果
AC × 73
AC × 3
セット名 テストケース
All sample_00, sample_01, sample_02, testcase_0_0, testcase_0_1, testcase_0_2, testcase_0_3, testcase_0_4, testcase_0_5, testcase_0_6, testcase_0_7, testcase_0_8, testcase_0_9, testcase_1_0, testcase_1_1, testcase_1_10, testcase_1_11, testcase_1_12, testcase_1_13, testcase_1_2, testcase_1_3, testcase_1_4, testcase_1_5, testcase_1_6, testcase_1_7, testcase_1_8, testcase_1_9, testcase_2_0, testcase_2_1, testcase_3_0, testcase_3_1, testcase_3_2, testcase_3_3, testcase_3_4, testcase_4_0, testcase_5_0, testcase_5_1, testcase_5_10, testcase_5_11, testcase_5_12, testcase_5_13, testcase_5_14, testcase_5_2, testcase_5_3, testcase_5_4, testcase_5_5, testcase_5_6, testcase_5_7, testcase_5_8, testcase_5_9, testcase_6_0, testcase_6_1, testcase_6_2, testcase_6_3, testcase_6_4, testcase_7_0, testcase_7_1, testcase_7_10, testcase_7_11, testcase_7_12, testcase_7_13, testcase_7_14, testcase_7_2, testcase_7_3, testcase_7_4, testcase_7_5, testcase_7_6, testcase_7_7, testcase_7_8, testcase_7_9, testcase_998244353, testcase_pair, testcase_powerful
Sample sample_00, sample_01, sample_02
ケース名 結果 実行時間 メモリ
sample_00 AC 1001 ms 3884 KiB
sample_01 AC 1001 ms 3928 KiB
sample_02 AC 1001 ms 3792 KiB
testcase_0_0 AC 1001 ms 3944 KiB
testcase_0_1 AC 1001 ms 3896 KiB
testcase_0_2 AC 1001 ms 3944 KiB
testcase_0_3 AC 1001 ms 3896 KiB
testcase_0_4 AC 1001 ms 3892 KiB
testcase_0_5 AC 1001 ms 3944 KiB
testcase_0_6 AC 1001 ms 3832 KiB
testcase_0_7 AC 1001 ms 3752 KiB
testcase_0_8 AC 1001 ms 3932 KiB
testcase_0_9 AC 1001 ms 3932 KiB
testcase_1_0 AC 1001 ms 3892 KiB
testcase_1_1 AC 1001 ms 3900 KiB
testcase_1_10 AC 1001 ms 3748 KiB
testcase_1_11 AC 1001 ms 4016 KiB
testcase_1_12 AC 1001 ms 3896 KiB
testcase_1_13 AC 1001 ms 3928 KiB
testcase_1_2 AC 1001 ms 4004 KiB
testcase_1_3 AC 1001 ms 3896 KiB
testcase_1_4 AC 1001 ms 3892 KiB
testcase_1_5 AC 1001 ms 3820 KiB
testcase_1_6 AC 1001 ms 3896 KiB
testcase_1_7 AC 1001 ms 4008 KiB
testcase_1_8 AC 1001 ms 3896 KiB
testcase_1_9 AC 1001 ms 3896 KiB
testcase_2_0 AC 1001 ms 3896 KiB
testcase_2_1 AC 1001 ms 3852 KiB
testcase_3_0 AC 1001 ms 3832 KiB
testcase_3_1 AC 1001 ms 3944 KiB
testcase_3_2 AC 1001 ms 3888 KiB
testcase_3_3 AC 1001 ms 3728 KiB
testcase_3_4 AC 1001 ms 3832 KiB
testcase_4_0 AC 1001 ms 4464 KiB
testcase_5_0 AC 1001 ms 4056 KiB
testcase_5_1 AC 1001 ms 3908 KiB
testcase_5_10 AC 1001 ms 3892 KiB
testcase_5_11 AC 1001 ms 3832 KiB
testcase_5_12 AC 1001 ms 3832 KiB
testcase_5_13 AC 1001 ms 3996 KiB
testcase_5_14 AC 1001 ms 4060 KiB
testcase_5_2 AC 1001 ms 4072 KiB
testcase_5_3 AC 1001 ms 3956 KiB
testcase_5_4 AC 1001 ms 4028 KiB
testcase_5_5 AC 1001 ms 4172 KiB
testcase_5_6 AC 1001 ms 3940 KiB
testcase_5_7 AC 1001 ms 4040 KiB
testcase_5_8 AC 1001 ms 4184 KiB
testcase_5_9 AC 1001 ms 4076 KiB
testcase_6_0 AC 1001 ms 4508 KiB
testcase_6_1 AC 1001 ms 4628 KiB
testcase_6_2 AC 1001 ms 4552 KiB
testcase_6_3 AC 1001 ms 4612 KiB
testcase_6_4 AC 1001 ms 4476 KiB
testcase_7_0 AC 1001 ms 3892 KiB
testcase_7_1 AC 1001 ms 4012 KiB
testcase_7_10 AC 1001 ms 3932 KiB
testcase_7_11 AC 1001 ms 3944 KiB
testcase_7_12 AC 1001 ms 3892 KiB
testcase_7_13 AC 1001 ms 3932 KiB
testcase_7_14 AC 1001 ms 3728 KiB
testcase_7_2 AC 1001 ms 3892 KiB
testcase_7_3 AC 1001 ms 3900 KiB
testcase_7_4 AC 1001 ms 3900 KiB
testcase_7_5 AC 1001 ms 3852 KiB
testcase_7_6 AC 1001 ms 3892 KiB
testcase_7_7 AC 1001 ms 3852 KiB
testcase_7_8 AC 1001 ms 3836 KiB
testcase_7_9 AC 1001 ms 3728 KiB
testcase_998244353 AC 1001 ms 4512 KiB
testcase_pair AC 1001 ms 3736 KiB
testcase_powerful AC 1001 ms 4012 KiB