結果
| 問題 |
No.168 ものさし
|
| コンテスト | |
| ユーザー |
machy
|
| 提出日時 | 2015-07-16 22:43:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 41 ms / 2,000 ms |
| コード長 | 1,109 bytes |
| コンパイル時間 | 778 ms |
| コンパイル使用メモリ | 77,604 KB |
| 実行使用メモリ | 19,800 KB |
| 最終ジャッジ日時 | 2024-12-24 07:10:33 |
| 合計ジャッジ時間 | 1,885 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;
typedef long long LL;
LL distance2(vector<pair<int,int> >& p, int p1, int p2){
LL dx = p[p1].first - p[p2].first;
LL dy = p[p1].second - p[p2].second;
return dx*dx + dy*dy;
}
int main(){
int N;
cin >> N;
vector<pair<int,int> > p(N);
for(int i = 0; i < N; i++){
cin >> p[i].first >> p[i].second;
}
priority_queue<pair<LL,int>, vector<pair<LL,int> >, greater<pair<LL,int> > > q;
q.push(pair<LL,int>(0, 0));
LL max_dist = 0;
vector<int> memo(N);
while(!q.empty()){
LL w = q.top().first;
int pos = q.top().second;
q.pop();
max_dist = max(max_dist, w);
if(pos == N-1) break;
if(memo[pos]) continue;
memo[pos] = 1;
for(int i = 0; i < N; i++){
LL dist2 = distance2(p, pos, i);
q.push(pair<LL,int>(dist2, i));
}
}
LL ans = LL(sqrt(max_dist)) / 10 * 10;
while(ans*ans < max_dist) ans += 10;
cout << ans << endl;
return 0;
}
machy