結果
問題 | No.94 圏外です。(EASY) |
ユーザー |
|
提出日時 | 2017-08-04 04:16:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 2,786 bytes |
コンパイル時間 | 1,915 ms |
コンパイル使用メモリ | 173,452 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 08:16:20 |
合計ジャッジ時間 | 2,787 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
// {{{ Templates#include <bits/stdc++.h>#define show(x) cerr << #x << " = " << x << endlusing namespace std;using ll = long long;using pii = pair<int, int>;using vi = vector<int>;template <typename T>ostream& operator<<(ostream& os, const vector<T>& v){os << "sz:" << v.size() << "\n[";for (const auto& p : v) {os << p << ",";}os << "]\n";return os;}template <typename S, typename T>ostream& operator<<(ostream& os, const pair<S, T>& p){os << "(" << p.first << "," << p.second<< ")";return os;}constexpr ll MOD = (ll)1e9 + 7LL;template <typename T>constexpr T INF = numeric_limits<T>::max() / 100;// }}}class DisjointSets{public:DisjointSets(const int v){m_parent.resize(v);m_rank.resize(v);m_size.resize(v);for (int i = 0; i < v; i++) {m_parent[i] = i;m_rank[i] = 0;m_size[i] = 1;}}bool same(const int a, const int b){return find(a) == find(b);}int find(const int a){if (m_parent[a] == a) {return a;} else {return m_parent[a] = find(m_parent[a]);}}void unite(const int a_, const int b_){const int a = find(a_);const int b = find(b_);if (a == b) {return;}if (m_rank[a] > m_rank[b]) {m_parent[b] = a;m_size[a] += m_size[b];} else {m_parent[a] = b;m_size[b] += m_size[a];}if (m_rank[a] == m_rank[b]) {m_rank[b]++;}}int getSize(const int a){return m_size[a];}private:vector<int> m_parent;vector<int> m_rank;vector<int> m_size;};int main(){cin.tie(0);ios::sync_with_stdio(false);int N;cin >> N;if (N == 0) {cout << 1 << endl;return 0;} else if (N == 1) {cout << 2 << endl;return 0;}vector<ll> x(N);vector<ll> y(N);DisjointSets uf(N);for (int i = 0; i < N; i++) {cin >> x[i] >> y[i];}for (int i = 0; i < N - 1; i++) {for (int j = i + 1; j < N; j++) {const ll dd = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);if (dd <= 100) {uf.unite(i, j);}}}ll maxi = 0;for (int i = 0; i < N - 1; i++) {for (int j = i + 1; j < N; j++) {if (uf.same(i, j)) {maxi = max(maxi, (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));}}}cout << fixed << setprecision(10) << 2.0 + sqrt(maxi) << endl;return 0;}