結果
問題 | No.168 ものさし |
ユーザー |
![]() |
提出日時 | 2015-03-20 14:01:58 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 273 ms / 2,000 ms |
コード長 | 1,222 bytes |
コンパイル時間 | 1,683 ms |
コンパイル使用メモリ | 169,476 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-12-24 07:04:32 |
合計ジャッジ時間 | 3,910 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>#define REP(i, x, n) for(int i = x; i < (int)(n); i++)#define rep(i, n) REP(i, 0, n)#define all(x) (x).begin(), (x).end()#define rall(x) (x).rbegin(), (x).rend()using namespace std;typedef long long ll;typedef long double ld;typedef unsigned long long ull;int N = 1000;vector<ll> X(N), Y(N);vector<vector<ll>> D(N, vector<ll>(N));ll dist(int i, int j) {ld d = sqrtl((X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]));if(d - int(d) == 0 && int(d) % 10 == 0) return int(d);return int(d)+10-int(d)%10;}int main() {int n;cin >> n;rep(i, n) cin >> X[i] >> Y[i];rep(i, n) rep(j, n) {D[i][j] = dist(i, j);}queue<pair<ll, int>> que;vector<ll> d(n, 10000000000000);d[0] = 0;ll ans = 100000000000;que.push(make_pair(0, 0));while(!que.empty()) {pair<ll, int> p = que.front(); que.pop();ll e = p.first; int v = p.second;if(v == n-1) ans = min(ans, e);rep(i, n) if(i != v) {if(d[i] <= max(D[v][i], e)) continue;d[i] = max(D[v][i], e);que.push(make_pair(d[i], i));}}cout << ans << endl;return 0;}