結果
問題 | No.94 圏外です。(EASY) |
ユーザー |
|
提出日時 | 2016-02-18 22:43:42 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 10 ms / 5,000 ms |
コード長 | 1,150 bytes |
コンパイル時間 | 1,093 ms |
コンパイル使用メモリ | 80,808 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-02 08:27:39 |
合計ジャッジ時間 | 1,694 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <functional> #include <cstdio> #include <math.h> #define repeat(i,n) for (int i = 0; (i) < (n); ++(i)) template <typename T> bool setmax(T & l, T const & r) { if (not (l < r)) return false; l = r; return true; } using namespace std; int sq(int x) { return x * x; } int main() { int n; cin >> n; vector<int> x(n), y(n); repeat (i,n) cin >> x[i] >> y[i]; if (n == 0) { cout << 1 << endl; return 0; } vector<vector<bool> > g(n, vector<bool>(n)); repeat (i,n) repeat (j,n) { g[i][j] = (sq(y[j] - y[i]) + sq(x[j] - x[i]) <= 100); } vector<bool> used(n); function<void (int, vector<int> &)> dfs = [&](int i, vector<int> & acc) { used[i] = true; acc.push_back(i); repeat (j,n) if (g[i][j] and not used[j]) dfs(j, acc); }; double ans = 0; repeat (i,n) if (not used[i]) { vector<int> acc; dfs(i, acc); for (int j : acc) for (int k : acc) { setmax(ans, sqrt(sq(y[k] - y[j]) + sq(x[k] - x[j]))); } } printf("%.12lf\n", ans + 2); return 0; }