結果

問題 No.94 圏外です。(EASY)
ユーザー k
提出日時 2021-03-02 17:32:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 1,596 bytes
コンパイル時間 1,949 ms
コンパイル使用メモリ 199,152 KB
最終ジャッジ日時 2025-01-19 09:25:27
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
class union_find {
int n;
int cnt; // number of connected components
vector<int> par;
vector<int> rank;
vector<int> sz; // size of each component
public:
union_find(int n) : n(n), cnt(n), par(n), rank(n), sz(n) {
for (int i = 0; i < n; i++) {
par[i] = i;
sz[i] = 1;
}
}
int find(int x) {
return par[x] == x ? x : par[x] = find(par[x]);
}
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y) return;
--cnt;
if (rank[x] < rank[y]) {
par[x] = y;
sz[y] += sz[x];
} else {
par[y] = x;
sz[x] += sz[y];
if (rank[x] == rank[y])
++rank[x];
}
}
bool same(int x, int y) {
return find(x) == find(y);
}
int compCnt() {
return cnt;
}
int size(int x) {
return sz[find(x)];
}
};
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
if (!n) {
cout << 1 << endl;
return 0;
}
vector<double> x(n), y(n);
for (int i = 0; i < n; i++)
cin >> x[i] >> y[i];
union_find tree(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
if ((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) <= 100)
tree.unite(i, j);
}
}
double ret = 0.0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
if (tree.same(i, j)) {
ret = max(ret, hypot(x[i] - x[j], y[i] - y[j]));
}
}
}
ret += 2.0;
cout << fixed << setprecision(12) << ret << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0