結果
| 問題 |
No.96 圏外です。
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-12-07 23:18:04 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,482 bytes |
| コンパイル時間 | 867 ms |
| コンパイル使用メモリ | 71,136 KB |
| 実行使用メモリ | 14,316 KB |
| 最終ジャッジ日時 | 2024-06-11 17:47:33 |
| 合計ジャッジ時間 | 14,737 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 TLE * 1 -- * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | scanf("%d",&N);
| ~~~~~^~~~~~~~~
main.cpp:35:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | for(int i=0;i<N;i++)scanf("%d%d",&v[i].first,&v[i].second);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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/20)break; //これを落とせるテストケースを作れるかどうかが問題なのかも
result=max(result,Z(v[it.second[i]],v[it.second[j]]));
}
}
}
printf("%.9f\n",sqrt(result)+2);
}