結果
| 問題 |
No.168 ものさし
|
| ユーザー |
oevl
|
| 提出日時 | 2019-03-19 23:23:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 88 ms / 2,000 ms |
| コード長 | 1,309 bytes |
| コンパイル時間 | 1,779 ms |
| コンパイル使用メモリ | 170,556 KB |
| 実行使用メモリ | 11,352 KB |
| 最終ジャッジ日時 | 2024-09-14 13:30:00 |
| 合計ジャッジ時間 | 3,388 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = 0; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
int N;
ll X[1000], Y[1000];
ll D[1000][1000];
class UnionFind{
public:
vector<int> uni;
UnionFind(int s) : uni(s, -1) {}
int root(int a){
if(uni[a] < 0) return a;
return uni[a] = root(uni[a]);
}
bool connect(int a, int b){
a = root(a);
b = root(b);
if(a == b) return false;
if(uni[a] > uni[b]) swap(a, b);
uni[a] = uni[a] + uni[b];
uni[b] = a;
return true;
}
bool isConnect(int a, int b){
return root(a) == root(b);
}
int size(int a){
return -uni[root(a)];
}
};
bool isOK(ll v) {
UnionFind uf(1000);
rep(i, 0, N) rep(j, 0, N) if(D[i][j] <= v * v * 100) uf.connect(i, j);
return uf.isConnect(0, N - 1);
}
int bs() {
int ng = 0;
int ok = 1e9;
while(abs(ok - ng) > 1) {
int mid = (ok + ng) / 2;
if(isOK(mid)) ok = mid;
else ng = mid;
}
return ok;
}
ll getDist(ll x, ll y, ll x2, ll y2) {
return (x-x2) * (x-x2) + (y-y2) * (y-y2);
}
ll solve() {
cin >> N;
rep(i, 0, N) cin >> X[i] >> Y[i];
rep(i, 0, N) rep(j, 0, N) D[i][j] = getDist(X[i], Y[i], X[j], Y[j]);
return 10 * bs();
}
int main(){
cout << solve() << endl;
return 0;
}
oevl