結果
問題 | No.168 ものさし |
ユーザー |
![]() |
提出日時 | 2015-06-01 19:50:08 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 100 ms / 2,000 ms |
コード長 | 1,580 bytes |
コンパイル時間 | 842 ms |
コンパイル使用メモリ | 89,420 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 07:09:12 |
合計ジャッジ時間 | 2,049 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <cassert>#include <functional>#include <set>#include <ctime>#include <cmath>#include <climits>#include <cstring>#include <string>#include <queue>#include <map>#include <vector>#include <algorithm>#include <iostream>#include <cstdio>#ifndef ONLINE_JUDGE //POJ# include <random># include <array># define mkt make_tuple# define empb emplace_back#endif#ifdef _LOCAL# include "for_local.h"#endifusing namespace std;typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull;#define repi(_I, _B, _E) for(int _I = (_B); (_I) < (_E); ++ (_I))#define rep(_I, _N) for(int _I = 0; (_I) < (_N); ++ (_I))#define mkp make_pair#define all(_X) (_X).begin(), (_X).end()#define scani(_V) std::scanf("%d", &_V)#define printi(_V) std::printf("%d", static_cast<int>(_V))int const INF = 1<<29;ll selfprod(ll x, ll y) { return x * x + y * y; }int n;vector<pair<int,int>> ps;bool pred(ll len) {vector<bool> done(n, false);priority_queue<int> qs;qs.push(0);done[0] = true;while ( !qs.empty() ) {int q = qs.top(); qs.pop();rep(i, n) {if ( !done[i]&& selfprod(ps[q].first - ps[i].first, ps[q].second - ps[i].second) <= len * len ) {if ( i == n - 1 ) return true;qs.push(i);done[i] = true;}}}return false;}//O(n (log n)^2)signed main() {cin >> n;rep(i, n) {int x, y;cin >> x >> y;ps.push_back(mkp(x,y));}ll low = 1, high = (ll)(1e9);rep(_, 50) {ll mid = low + (high - low) / 2;(pred(mid * 10) ? high : low) = mid;}cout << (high * 10) << endl;return 0;}