結果

問題 No.2520 L1 Explosion
ユーザー MasKoaTSMasKoaTS
提出日時 2022-02-21 17:37:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,243 bytes
コンパイル時間 984 ms
コンパイル使用メモリ 83,700 KB
実行使用メモリ 47,376 KB
最終ジャッジ日時 2023-10-25 00:36:29
合計ジャッジ時間 3,682 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#define rep(i, l, n) for (int i = (l); i < (n); i++)
using namespace std;
using ll = long long;
using Pair = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T> >;


bool func(ll N, VV<Pair>& route, ll d) {
	V<ll> c(N);
	rep(v, 0, N) {
		if (c[v]) {
			continue;
		}
		c[v] = 1;
		V<ll> que = { v };
		while (que.empty() == false) {
			ll now = que[que.size() - 1];
			que.pop_back();
			for (auto& r : route[now]) {
				ll nv = r.first, nd = r.second;
				if (nd <= d) {
					continue;
				}
				if (c[nv] == 0) {
					c[nv] = -c[now];
					que.push_back(nv);
				}
				else if (c[nv] == c[now]) {
					return false;
				}
			}
		}
	}
	return true;
}


int main(void) {
	ll N;	cin >> N;
	VV<ll> P(N, V<ll>(2));
	rep(i, 0, N) {
		cin >> P[i][0] >> P[i][1];
	}

	VV<Pair> route(N, V<Pair>(0));
	rep(i, 0, N - 1) {
		rep(j, i + 1, N) {
			ll d = abs(P[i][0] - P[j][0]) + abs(P[i][1] - P[j][1]);
			route[i].push_back({ j,d });
			route[j].push_back({ i,d });
		}
	}

	ll ok = 4000000001, ng = -1;
	while (ok - ng > 1) {
		ll d = (ok + ng) / 2;
		if (func(N, route, d)) {
			ok = d;
		}
		else {
			ng = d;
		}
	}

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

	return 0;
}
0