結果
問題 | No.168 ものさし |
ユーザー |
![]() |
提出日時 | 2015-10-11 23:42:01 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 1,337 bytes |
コンパイル時間 | 2,042 ms |
コンパイル使用メモリ | 166,148 KB |
実行使用メモリ | 12,160 KB |
最終ジャッジ日時 | 2024-12-24 07:12:28 |
合計ジャッジ時間 | 2,762 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include "bits/stdc++.h"using namespace std;#define int long long#define REP(i, n) for(int i=0; i<(n); i++)struct P { int x, y; P(){}; P(int _x, int _y): x(_x), y(_y){}; };int distance2(P a, P b) {return (int)pow(a.x - b.x, 2) + (int)pow(a.y - b.y, 2);}int N,T;int V[1111][1111];vector<P> P(1111);bool isok(int len) {int border = pow(len, 2);queue<int> que;que.push(0);vector<bool> checked(N, false);while(que.size()) {int i = que.front();que.pop();if (checked[i]) continue;checked[i] = true;REP(j,N) {if (checked[j]) continue;if (V[i][j] <= border) {if (j == N-1) return true;que.push(j);}}}return false;}signed main(){cin >> N;REP(i,N) cin >> P[i].x >> P[i].y;REP(i,N) REP(j,i) {int d = distance2(P[i], P[j]);V[i][j] = V[j][i] = d;}int high = (int)1e9 * 2;int low = 0;while(high - low > 10) {int mid = (high + low) /2;if (isok(mid)) {high = mid;} else {low = mid;}}int len = (low / 10) * 10;REP(i,10) {if (isok(len)) {break;}len += 10;}cout << len << endl;return 0;}