結果
| 問題 |
No.2520 L1 Explosion
|
| コンテスト | |
| ユーザー |
MasKoaTS
|
| 提出日時 | 2022-02-20 13:09:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,491 bytes |
| コンパイル時間 | 1,005 ms |
| コンパイル使用メモリ | 91,068 KB |
| 最終ジャッジ日時 | 2025-01-28 01:08:16 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 22 |
ソースコード
#include <iostream>
#include <vector>
#include <set>
#define rep(i, l, n) for (int i = (l); i < (n); i++)
using namespace std;
using Pair = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T> >;
bool func(int N, VV<Pair>&route, V<int>&lis, int k) {
V<int> c(N);
rep(v, 0, N) {
if (c[v]) {
continue;
}
c[v] = 1;
V<int> que = { v };
while (que.empty() == false) {
int now = que[que.size() - 1];
que.pop_back();
for (auto& r : route[now]) {
int nv = r.first, nd = r.second;
if (nd <= lis[k]) {
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) {
int N; cin >> N;
VV<int> P(N, V<int>(2));
rep(i, 0, N) {
cin >> P[i][0] >> P[i][1];
}
set<int> st = { 0 };
VV<int> dist(N, V<int>(N));
VV<Pair> route(N, V<Pair>(0));
rep(i, 0, N - 1) {
rep(j, i + 1, N) {
dist[i][j] = dist[j][i] = abs(P[i][0] - P[j][0]) + abs(P[i][1] - P[j][1]);
route[i].push_back({ j,dist[i][j] });
route[j].push_back({ i,dist[i][j] });
st.insert(-dist[i][j]);
}
}
V<int> lis = {};
for (auto itr = st.begin(); itr != st.end(); itr++) {
lis.push_back(-(*itr));
}
int ok = 0, ng = lis.size();
while (ng - ok > 1) {
int k = (ok + ng) / 2;
if (func(N, route, lis, k)) {
ok = k;
}
else {
ng = k;
}
}
int ans = lis[ok] / 2;
cout << ans << endl;
return 0;
}
MasKoaTS