結果
問題 | No.168 ものさし |
ユーザー |
|
提出日時 | 2016-08-30 21:32:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 168 ms / 2,000 ms |
コード長 | 2,780 bytes |
コンパイル時間 | 1,025 ms |
コンパイル使用メモリ | 93,924 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 07:14:37 |
合計ジャッジ時間 | 2,667 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <iostream>#include <queue>#include <map>#include <list>#include <vector>#include <string>#include <stack>#include <limits>#include <cassert>#include <fstream>#include <cstring>#include <cmath>#include <bitset>#include <iomanip>#include <algorithm>#include <functional>#include <cstdio>#include <ciso646>using namespace std;#define FOR(i,a,b) for (int i=(a);i<(b);i++)#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)#define REP(i,n) for (int i=0;i<(n);i++)#define RREP(i,n) for (int i=(n)-1;i>=0;i--)#define inf 0x3f3f3f3f#define INF INT_MAX/3#define PB push_back#define MP make_pair#define ALL(a) (a).begin(),(a).end()#define SET(a,c) memset(a,c,sizeof a)#define CLR(a) memset(a,0,sizeof a)#define pii pair<int,int>#define pcc pair<char,char>#define pic pair<int,char>#define pci pair<char,int>#define VS vector<string>#define VI vector<int>#define DEBUG(x) cout<<#x<<": "<<x<<endl#define MIN(a,b) (a>b?b:a)#define MAX(a,b) (a>b?a:b)#define pi 2*acos(0.0)#define INFILE() freopen("in0.txt","r",stdin)#define OUTFILE()freopen("out0.txt","w",stdout)#define in scanf#define out printf#define ll long long#define ull unsigned long long#define eps 1e-14#define FST first#define SEC secondclass union_find {private:vector<int> par;vector<int> rank;public:union_find(int N):par(N), rank(N) {for (int i = 0; i < N; ++i) {par[i] = i;rank[i] = 0;}}int find(int x) {if (par[x] == x) {return x;}else {return par[x] = find(par[x]);}}void unite(int x, int y) {x = find(x);y = find(y);if (x == y) return;if (rank[x] < rank[y]) {par[x] = y;}else {par[y] = x;if (rank[x] == rank[y]) rank[x]++;}}bool same(int x, int y) {return find(x) == find(y);}};template <class T>struct vector2 {T x;T y;vector2(T x_, T y_) :x(x_), y(y_) {}vector2() :x(0), y(0) {}vector2 operator + (const vector2<T>& right) { return vector2(x + right.x, y + right.y); }vector2 operator - (const vector2<T>& right) { return vector2(x - right.x, y - right.y); }T dot(const vector2<T>& right) { return x*right.x + y*right.y; }T det(const vector2<T>& right) { return (x*right.y) + (-y*right.x); }T dist2(const vector2<T>& right) { return (right.x-x)*(right.x-x) + (right.y-y)*(right.y-y); }T ownDot(const vector2<T>& right) { return x*x+y*y; }};int main() {int N; cin >> N;vector<vector2<ll> > P(N); REP(i, N) cin >> P[i].x >> P[i].y;ll low = 0.0, high = 10e9*2;REP(count, 100) {ll mid = (low + high) / 2.0;union_find uf(N);REP(i, N) REP(j, N) {if (P[i].dist2(P[j]) <= mid*mid) {uf.unite(i, j);}}if (uf.same(0, N - 1)) high = mid;else low = mid;}cout << int(ceil(high/ 10.0))*10 << endl;return 0;}