結果
| 問題 |
No.168 ものさし
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-03-20 01:01:04 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 68 ms / 2,000 ms |
| コード長 | 1,435 bytes |
| コンパイル時間 | 1,659 ms |
| コンパイル使用メモリ | 169,592 KB |
| 実行使用メモリ | 11,516 KB |
| 最終ジャッジ日時 | 2024-12-24 07:01:15 |
| 合計ジャッジ時間 | 3,057 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define REP(i, n) for(int(i)=0;(i)<(n);++(i))
#define FOR(i, f, t) for(int(i)=(f);(i)<(t);(++i))
#define EACH(it, c) for(auto it=(c).begin();it!=(c).end();++it)
const int MOD = int(1e9+7);
int N,M,W,H;
ll X[1111],Y[1111];
class uf_ {
public:
vector<int> node;
uf_(int n) : node(n, -1){;}
void con(int n, int m){
n = root(n); m = root(m); if(n == m) return;
node[n] += node[m]; node[m] = n;
}
bool is_con(int n, int m){ return root(n) == root(m); }
int root(int n){ return (node[n] < 0) ? n : node[n] = root(node[n]); }
int size(int n){ return -node[root(n)]; }
};
int main(){
do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0);
cin >> N;
REP(i,N) cin >> X[i] >> Y[i];
vector<pair<ll,pair<int,int> > > v;
REP(i,N) FOR(j,i+1,N){
ll d = (X[i]-X[j])*(X[i]-X[j]) + (Y[i]-Y[j])*(Y[i]-Y[j]);
v.push_back(make_pair(d, make_pair(i,j)));
}
sort(v.begin(), v.end());
uf_ uf(N);
ll d = 0;
EACH(it, v){
d = it->first;
int u = it->second.first, v = it->second.second;
uf.con(u,v);
if(uf.is_con(0,N-1)) break;
}
ll res = int(sqrt(d+.0)/10)*10;
while(res*res < d) res+=10;
cout << res << endl;
return 0;
}