結果
| 問題 | No.1997 X Lighting | 
| コンテスト | |
| ユーザー |  MasKoaTS | 
| 提出日時 | 2022-02-21 17:40:33 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,250 bytes | 
| コンパイル時間 | 873 ms | 
| コンパイル使用メモリ | 81,516 KB | 
| 最終ジャッジ日時 | 2025-01-28 01:16:23 | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 2 RE * 1 | 
| other | WA * 8 RE * 22 | 
ソースコード
//TLE
#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;
}
            
            
            
        