結果
問題 | No.96 圏外です。 |
ユーザー | ciel |
提出日時 | 2014-12-07 23:14:49 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,394 bytes |
コンパイル時間 | 767 ms |
コンパイル使用メモリ | 83,148 KB |
実行使用メモリ | 14,008 KB |
最終ジャッジ日時 | 2023-09-02 11:06:30 |
合計ジャッジ時間 | 12,454 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | WA | - |
testcase_05 | AC | 4 ms
4,376 KB |
testcase_06 | AC | 5 ms
4,380 KB |
testcase_07 | AC | 7 ms
4,380 KB |
testcase_08 | WA | - |
testcase_09 | AC | 13 ms
4,580 KB |
testcase_10 | AC | 18 ms
4,688 KB |
testcase_11 | AC | 22 ms
5,876 KB |
testcase_12 | AC | 26 ms
7,320 KB |
testcase_13 | AC | 39 ms
5,848 KB |
testcase_14 | AC | 45 ms
8,204 KB |
testcase_15 | AC | 63 ms
6,536 KB |
testcase_16 | AC | 68 ms
10,336 KB |
testcase_17 | AC | 75 ms
14,008 KB |
testcase_18 | AC | 88 ms
11,320 KB |
testcase_19 | AC | 88 ms
11,284 KB |
testcase_20 | AC | 2,019 ms
5,692 KB |
testcase_21 | AC | 1,769 ms
4,500 KB |
testcase_22 | TLE | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
ソースコード
#include <vector> #include <unordered_map> #include <algorithm> #include <cstdio> #include <cmath> using namespace std; class union_find{ int *parent,n; public: int root(int a){return parent[a]==a?a:(parent[a]=root(parent[a]));} union_find(int _n){ n=_n; parent=new int[n]; for(int i=0;i<n;i++)parent[i]=i; } ~union_find(){delete []parent;} int unite(int a,int b){ int x=root(a),y=root(b);if(x==y)return 0; parent[y]=x; return 1; } }; #define X(a,b,t) (((a).t-(b).t)*((a).t-(b).t)) #define Z(a,b) (X(a,b,first) + X(a,b,second)) int main(){ int N; scanf("%d",&N); if(N==0){ puts("1"); return 0; } vector<pair<int,int> >v(N); for(int i=0;i<N;i++)scanf("%d%d",&v[i].first,&v[i].second); sort(v.begin(),v.end()); union_find uf(N); for(int i=0;i<N-1;i++){ int upper=upper_bound(v.begin(),v.end(),make_pair(v[i].first+10,9999999))-v.begin(); for(int j=i+1;j<upper;j++){ if(Z(v[i],v[j])<=100)uf.unite(i,j); } } int result=0; unordered_map<int,vector<int> >z; for(int i=0;i<N;i++){ int r=uf.root(i); z[r].push_back(i); } for(auto &it:z){ for(int i=0;i<it.second.size()-1;i++){ for(int j=it.second.size()-1;j>i;j--){ if(X(v[it.second[i]],v[it.second[j]],first)<result/5)break; result=max(result,Z(v[it.second[i]],v[it.second[j]])); } } } printf("%.9f\n",sqrt(result)+2); }