結果
問題 | No.168 ものさし |
ユーザー |
![]() |
提出日時 | 2015-06-11 23:43:50 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 138 ms / 2,000 ms |
コード長 | 1,251 bytes |
コンパイル時間 | 819 ms |
コンパイル使用メモリ | 81,756 KB |
実行使用メモリ | 19,472 KB |
最終ジャッジ日時 | 2024-12-24 07:09:26 |
合計ジャッジ時間 | 2,708 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include<iostream> #include<queue> #include<algorithm> #include<map> #include<vector> #include<functional> using namespace std; typedef long long LL; typedef pair<LL, LL> PI; typedef vector<PI> VP; typedef pair<LL, int> PL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; #define x(_v) _v.first #define y(_v) _v.second #define cost(_v) _v.first #define to(_v) _v.second #define mp(_x,_y) make_pair(_x,_y) #define dist(_v,_u) (x(_v)-x(_u))*(x(_v)-x(_u))+(y(_v)-y(_u))*(y(_v)-y(_u)) const LL INF = 2*(LL)1e9; int main(){ int N; cin >> N; VP p(N); for (auto& v: p){ cin >> x(v) >> y(v); } VVLL edge(N, VLL(N)); for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ edge[i][j] = dist(p[i], p[j]); } } priority_queue<PL,vector<PL>,greater<PL>> que; vector<LL> used(N, -1); que.push(mp(0, 0)); while (que.empty() == false){ auto v = que.top(); que.pop(); if (used[to(v)]>=0)continue; used[to(v)] = cost(v); for (int i = 0; i < N; i++){ if (to(v)!=i&&used[i]==-1){ que.push(mp(max(used[to(v)],edge[to(v)][i]), i)); } } } LL res = used[N - 1]; LL l = 0; LL h = INF; while (h - l > 1){ LL m = ((l + h) / 2)*10; if (res <= m*m)h = m / 10; else l = m / 10; } cout << h * 10 << endl; return 0; }