結果
問題 | No.94 圏外です。(EASY) |
ユーザー |
![]() |
提出日時 | 2017-05-24 22:52:07 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 1,351 bytes |
コンパイル時間 | 1,299 ms |
コンパイル使用メモリ | 162,612 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 08:13:16 |
合計ジャッジ時間 | 2,149 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
#include"bits/stdc++.h"//#include<bits/stdc++.h>using namespace std;#define print(x) cout<<x<<endl;#define rep(i,a,b) for(int i=a;i<b;i++)#define REP(i,a) for(int i=0;i<a;i++)typedef long long ll;typedef pair<int, int> PI;typedef pair<int, PI> V;const ll mod = 10000000000;//union-find木実装int par[100002];int ran[100002];//初期化void init(int n) {rep(i, 0, n) {par[i] = i;ran[i] = 0;}}//木の根を求めるint find(int x) {if (par[x] == x) {return x;}else {return par[x] = find(par[x]);}}//xとyの属する集合を併合void unite(int x, int y) {x = find(x);y = find(y);if (x == y) return;if (ran[x] < ran[y]) {par[x] = y;}else {par[y] = x;if (ran[x] == ran[y])ran[x]++;}}//xとyが同じ集合かどうかbool same(int x, int y) {return find(x) == find(y);}int main() {int n;double x[1002], y[1002];double ans = 0;int count = 0;cin >> n;REP(i, n)cin >> x[i] >> y[i];init(n);REP(i, n)rep(j, i + 1, n) {if (pow(x[i] - x[j], 2.0) + pow(y[i] - y[j], 2.0) <= 100.0) {unite(i,j);}}REP(i, n)rep(j, i + 1, n) {if (same(i, j)) {count += 1;ans = max(ans, sqrt(pow(x[i] - x[j], 2.0) + pow(y[i] - y[j], 2.0)) + 2.0);}}if (n == 0)ans = 1;else if (count == 0||n == 1)ans = 2;printf("%10lf\n", ans);return 0;}