結果
| 問題 | No.168 ものさし |
| コンテスト | |
| ユーザー |
izuru_matsuura
|
| 提出日時 | 2016-08-30 21:25:03 |
| 言語 | C++11(gcc12) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 237 ms / 2,000 ms |
| コード長 | 1,929 bytes |
| 記録 | |
| コンパイル時間 | 3,401 ms |
| コンパイル使用メモリ | 172,792 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-03-08 18:21:33 |
| 合計ジャッジ時間 | 5,144 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
namespace {
typedef long double real;
typedef long long ll;
template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
if (vs.empty()) return os << "[]";
os << "[" << vs[0];
for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
return os << "]";
}
template<class T> istream& operator>>(istream& is, pair<T,T>& p) {
return is >> p.first >> p.second;
}
template<class T> istream& operator>>(istream& is, vector<T>& vs) {
for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
return is;
}
int N;
vector<pair<int,int>> P;
void input() {
cin >> N;
P.resize(N); cin >> P;
}
ll dist2(pair<int,int> a, pair<int,int> b) {
ll dx = a.first - b.first;
ll dy = a.second - b.second;
return dx*dx + dy*dy;
}
struct UnionFind {
vector<int> P;
UnionFind(int N) : P(N, -1) {}
int root(int x) {
if (P[x] < 0) return x;
return P[x] = root(P[x]);
}
void merge(int x, int y) {
x = root(x); y = root(y);
if (x == y) return;
P[x] = y;
}
bool query(int x, int y) {
return root(x) == root(y);
}
};
bool C(ll r) {
UnionFind uf(N);
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
if (dist2(P[i], P[j]) <= r*r) {
uf.merge(i, j);
}
}
}
return uf.query(0, N - 1);
}
void solve() {
ll lb = 0, ub = ll(2e9);
for (int i = 0; i < 200; i++) {
ll mid = (lb + ub) / 2LL;
(C(mid) ? ub : lb) = mid;
}
cout << (ub + 9) / 10 * 10 << endl;
}
}
int main() {
input(); solve();
return 0;
}
izuru_matsuura