結果
問題 |
No.94 圏外です。(EASY)
|
ユーザー |
|
提出日時 | 2016-09-25 18:24:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 33 ms / 5,000 ms |
コード長 | 1,551 bytes |
コンパイル時間 | 1,606 ms |
コンパイル使用メモリ | 170,656 KB |
実行使用メモリ | 7,576 KB |
最終ジャッジ日時 | 2024-06-26 08:03:48 |
合計ジャッジ時間 | 2,764 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include "bits/stdc++.h" #define REP(i,a,b) for(int i=a;i<b;++i) #define rep(i,n) REP(i,0,n) #define ll long long #define ull unsigned ll typedef long double ld; #define ALL(a) begin(a),end(a) #define ifnot(a) if(not a) #define dump(x) cerr << #x << " = " << (x) << endl using namespace std; // #define int ll #ifdef _MSC_VER const bool test = true; #else const bool test = false; #endif int dx[] = { 0,1,0,-1 }; int dy[] = { 1,0,-1,0 }; #define INF (1 << 28) ull mod = (int)1e9 + 7; //..................... #define MAX (int)1e6 + 5 struct UnionFind { vector<int> data; UnionFind(int size) : data(size, -1) { } bool unite(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } return x != y; } bool same(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } }; int N; double x[1005], y[1005]; void solve() { UnionFind uf((int)1e6); double ans = 0; rep(i, N) { cin >> x[i] >> y[i]; } rep(i, N) rep(j, N) { if (hypot(x[i] - x[j], y[i] - y[j]) - 1e-6 < 10) { uf.unite(i, j); } // dump(hypot(x[i] - x[j], y[i] - y[j])); } rep(i, N) rep(j, N) { if (uf.same(i, j)) { ans = max(ans, hypot(x[i] - x[j], y[i] - y[j])); } } if (N == 0) puts("1"); else { ans += 2; printf("%.20lf\n", ans); } } signed main() { while (cin >> N) { solve(); } return 0; }