結果

問題 No.168 ものさし
コンテスト
ユーザー mamekin
提出日時 2015-04-05 16:11:42
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,306 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 815 ms
コンパイル使用メモリ 119,480 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-30 03:55:41
合計ジャッジ時間 1,940 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for(int i=0; i<n; ++i)
        cin >> x[i] >> y[i];

    multimap<int, int> mm;
    vector<int> dp(n, INT_MAX);
    mm.insert(make_pair(0, 0));
    dp[0] = 0;
    while(!mm.empty()){
        int len, pos;
        tie(len, pos) = *mm.begin();
        mm.erase(mm.begin());
        if(dp[pos] < len)
            continue;

        for(int i=0; i<n; ++i){
            long long dx = x[pos] - x[i];
            long long dy = y[pos] - y[i];
            long long dist = dx * dx + dy * dy;

            int len2 = (int)sqrt(dist);
            if(len2 * (long long)len2 < dist)
                ++ len2;

            len2 = max(len2, len);
            if(len2 < dp[i]){
                mm.insert(make_pair(len2, i));
                dp[i] = len2;
            }
        }
    }

    int ans = (dp[n-1] + 9) / 10 * 10;
    cout << ans << endl;

    return 0;
}
0