結果
問題 |
No.168 ものさし
|
ユーザー |
![]() |
提出日時 | 2017-09-20 20:08:26 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,276 bytes |
コンパイル時間 | 1,555 ms |
コンパイル使用メモリ | 160,112 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 09:14:17 |
合計ジャッジ時間 | 5,923 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 RE * 1 |
other | AC * 4 RE * 15 |
ソースコード
#include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define REP(i,x,n) for(int i=x;i<n;i++) #define ALL(v) (v).begin(),(v).end() #define MP(a,b) make_pair(a,b) typedef long long LL; typedef pair<int, int> PI; typedef vector<int> VI; const LL MOD = 1000000007LL; LL X[1000]; LL Y[1000]; struct UnionFind { int *par; int *rank; int size; UnionFind(int n) :size(n) { par = new int(size); rank = new int(size); rep(i, size) par[i] = i, rank[i] = 0; } void clear() { rep(i, size) par[i] = i, rank[i] = 0; } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rank[x] < rank[y]) { par[x] = y; } else { par[y] = x; if (rank[x] == rank[y]) rank[x]++; } } int find(int x) { if (par[x] == x) return x; return par[x] = find(par[x]); } bool same(int x, int y) { return find(x) == find(y); } }; int main() { int N; cin >> N; rep(i, N) { cin >> X[i] >> Y[i]; } LL l = 0, r = 2 * 1000000000; UnionFind U(N); while (r - l > 1) { LL m = (l + r) / 2; U.clear(); rep(i, N) { rep(j, N) { if ((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]) <= (m*10)*(m*10)) { U.unite(i, j); } } } if (U.same(0, N - 1)) r = m; else l = m; } cout << r*10 << endl; }