結果

問題 No.168 ものさし
ユーザー noko2250noko2250
提出日時 2015-03-20 14:01:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 1,222 bytes
コンパイル時間 2,705 ms
コンパイル使用メモリ 154,596 KB
実行使用メモリ 11,536 KB
最終ジャッジ日時 2023-08-25 20:51:24
合計ジャッジ時間 3,982 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
11,344 KB
testcase_01 AC 7 ms
11,236 KB
testcase_02 AC 7 ms
11,292 KB
testcase_03 AC 7 ms
11,372 KB
testcase_04 AC 7 ms
11,216 KB
testcase_05 AC 7 ms
11,276 KB
testcase_06 AC 7 ms
11,224 KB
testcase_07 AC 7 ms
11,224 KB
testcase_08 AC 7 ms
11,212 KB
testcase_09 AC 8 ms
11,328 KB
testcase_10 AC 9 ms
11,272 KB
testcase_11 AC 33 ms
11,380 KB
testcase_12 AC 86 ms
11,332 KB
testcase_13 AC 117 ms
11,480 KB
testcase_14 AC 127 ms
11,344 KB
testcase_15 AC 8 ms
11,204 KB
testcase_16 AC 8 ms
11,244 KB
testcase_17 AC 8 ms
11,304 KB
testcase_18 AC 10 ms
11,536 KB
testcase_19 AC 166 ms
11,368 KB
testcase_20 AC 259 ms
11,444 KB
testcase_21 AC 115 ms
11,348 KB
testcase_22 AC 195 ms
11,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0