結果
問題 | No.168 ものさし |
ユーザー |
![]() |
提出日時 | 2018-01-11 22:11:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,270 bytes |
コンパイル時間 | 1,869 ms |
コンパイル使用メモリ | 172,884 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 07:22:54 |
合計ジャッジ時間 | 6,207 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 4 |
other | RE * 19 |
コンパイルメッセージ
main.cpp: In function 'bool check(long long int)': main.cpp:31:1: warning: control reaches end of non-void function [-Wreturn-type] 31 | } | ^
ソースコード
#include<bits/stdc++.h>using namespace std;struct Point{long long int n, x, y;};int n;vector<Point> v;long long int get_distance(Point a, Point b){return (b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y);}bool check(long long int x){bool visited[n];for(int i=0;i<n;++i)visited[i] = false;queue<Point> que;visited[0] = true;que.push(v[0]);while(!que.empty()){Point curr = que.front(); que.pop();if(curr.n == n-1)return true;for(int i=1;i<n;++i){if(!visited[i] && get_distance(v[i], curr) <= x){que.push(v[i]);visited[i] = true;}}}}int main(){cin >> n;for(int i=0;i<n;++i){int x, y;cin >> x >> y;v.push_back((Point){i, x, y});}long long int ok = 2000000000000000000, ng = 0;while(abs(ok-ng) > 1){long long int mid = (ok + ng) / 2;if(check(mid))ok = mid;else ng = mid;}long long int lb = 0, ub = 1414213563;while(abs(ub-lb) > 1){long long int mid = (ub + lb) / 2;if(mid * mid < ok)lb = mid;else ub = mid;}if((ub%10) != 0)ub += 10 - (ub%10);cout << ub << endl;return 0;}