結果

問題 No.1997 X Lighting
ユーザー MasKoaTSMasKoaTS
提出日時 2022-02-20 17:01:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,434 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 82,204 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 11:59:52
合計ジャッジ時間 4,913 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 RE -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

//嘘解法

#include <iostream>
#include <vector>
#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define chmin(x, y) if(x > (y)){ x = (y); }
#define chmax(x, y) if(x < (y)){ x = (y); }
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T> >;

int N;
ll max_x, max_y, min_x, min_y;


bool func(VV<ll>& P, ll k) {
	k *= 2;
	VV<int> block = { {0,0},{0,0} };
	for (auto& p : P) {
		ll x = p[0], y = p[1];
		if ((x < max_x - k and x > min_x + k) or (y < max_y - k and y > min_y + k)) {
			return false;
		}
		if (x < max_x - k and y < max_y - k) {
			block[0][0] = 1;
		}
		if (x > min_x + k and y < max_y - k) {
			block[1][0] = 1;
		}
		if (x < max_x - k and y > min_y + k) {
			block[0][1] = 1;
		}
		if (x > min_x + k and y > min_y + k) {
			block[1][1] = 1;
		}
	}
	if ((block[0][0] | block[1][1]) == 0 or (block[0][1] | block[1][0]) == 0) {
		return true;
	}
	return false;
}


int main(void) {
	cin >> N;
	VV<ll> P(N, V<ll>(2));
	rep(i, 0, N) {
		ll x, y;	cin >> x >> y;
		P[i] = { x + y,x - y };
	}

	max_x = min_x = P[0][0];
	max_y = min_y = P[0][1];
	rep(i, 1, N) {
		chmax(max_x, P[i][0]);	chmax(max_y, P[i][1]);
		chmin(min_x, P[i][0]);	chmin(min_y, P[i][1]);
	}

	ll ok = 1000000001, ng = -1;
	while (ok - ng > 1) {
		ll k = (ok + ng) / 2;
		if (func(P, k)) {
			ok = k;
		}
		else {
			ng = k;
		}
	}

	ll ans = ok;
	cout << ans << endl;

	return 0;
}
0