結果
問題 | No.94 圏外です。(EASY) |
ユーザー |
![]() |
提出日時 | 2016-02-18 21:09:00 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 3,055 bytes |
コンパイル時間 | 1,496 ms |
コンパイル使用メモリ | 166,632 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 07:48:07 |
合計ジャッジ時間 | 2,481 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>using namespace std;namespace {typedef double real;typedef long long ll;real EPS = 1e-8;template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {if (vs.empty()) return os << "[]";os << "[" << vs[0];for (int i = 1; i < vs.size(); i++) os << " " << vs[i];return os << "]";}template<class T> istream& operator>>(istream& is, vector<T>& vs) {for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;return is;}struct Point {real x, y;Point() {}Point(real x, real y) : x(x), y(y) {}Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }Point operator*(real k) const { return Point(k * x, k * y); }Point operator/(real k) const { return Point(x / k, y / k); }};real dot(const Point& a, const Point& b) { return a.x * b.x + a.y * b.y; }real cross(const Point& a, const Point& b) { return a.x * b.y - a.y * b.x; }real norm(const Point& a) { return sqrt(dot(a, a)); }Point rot90(const Point& p) { return Point(-p.y, p.x); } // 反時計回りに90度回転real angle(const Point& a) { return atan2(a.y, a.x); } // x軸を反時計回りに何ラジアン回転させれば点aに乗るかostream& operator<<(ostream& os, const Point& p) { return os << "(" << p.x << "," << p.y << ")"; }istream& operator>>(istream& is, Point& p) { return is >> p.x >> p.y; }struct UnionFind {int N;vector<int> P;UnionFind(int N) : N(N) {P.clear(); P.resize(N, -1);}int root(int x) {if (P[x] == -1) return x;return P[x] = root(P[x]);}int query(int x, int y) {return root(x) == root(y);}void merge(int x, int y) {x = root(x); y = root(y);if (x == y) return;P[x] = y;}};int N;vector<Point> P;void input() {cin >> N;P.resize(N);cin >> P;}void solve() {real ans = 0;UnionFind uf(N);for (int i = 0; i < N; i++) {for (int j = i + 1; j < N; j++) {const Point& a = P[i];const Point& b = P[j];if ( norm(a - b) < 10.0 + EPS ) {uf.merge(i, j);}}}for (int i = 0; i < N; i++) {for (int j = i + 1; j < N; j++) {const Point& a = P[i];const Point& b = P[j];if (uf.query(i, j)) {ans = max(ans, norm(a - b));}}}if (N == 0) {cout << setprecision(12) << 1 << endl;} else {cout << setprecision(12) << ans + 2 << endl;}}}int main() {input(); solve();return 0;}