結果

問題 No.168 ものさし
ユーザー codershifthcodershifth
提出日時 2015-12-29 15:21:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 1,626 bytes
コンパイル時間 1,214 ms
コンパイル使用メモリ 153,272 KB
実行使用メモリ 11,160 KB
最終ジャッジ日時 2023-08-25 21:00:18
合計ジャッジ時間 2,651 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
4,932 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 18 ms
4,556 KB
testcase_12 AC 45 ms
8,512 KB
testcase_13 AC 56 ms
11,012 KB
testcase_14 AC 40 ms
10,884 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 70 ms
10,948 KB
testcase_20 AC 39 ms
10,940 KB
testcase_21 AC 111 ms
11,160 KB
testcase_22 AC 46 ms
10,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()

using namespace std;

class Ruler {
public:
    void solve(void) {
        int N;
        cin>>N;

        vector<ll> xs(N);
        vector<ll> ys(N);
        REP(i,N)
        {
            cin>>xs[i]>>ys[i];
        }

        vector<vector<ll>> dist(N,vector<ll>(N,0));
        REP(i,N)
        REP(j,i+1)
        {
            ll dx = xs[i]-xs[j];
            ll dy = ys[i]-ys[j];
            // (10^9)^2 を double で扱うと精度落ちするので long long で扱う
            dist[i][j] = dist[j][i] = dx*dx+dy*dy;
        }
        ll low = 0;
        ll high = 2*1E+9+1;

        vector<bool> vis(N,false);
        while (low+1 < high)
        {
            ll mid = (low+high)/2;

            fill(RANGE(vis),false);
            function<void(int)> dfs = [&](int v) {
                vis[v] = true;
                REP(u,N)
                {
                    if (vis[u])
                        continue;
                    if (dist[v][u] > mid*mid)
                        continue;
                    dfs(u);
                }
            };
            dfs(0);
            if (vis[N-1])
                high = mid;
            else
                low = mid;
        }
        cout<<(ll)ceil(high/10.0)*10<<endl;
    }
};

#if 1
int main(int argc, char *argv[])
{
        ios::sync_with_stdio(false);
        auto obj = new Ruler();
        obj->solve();
        delete obj;
        return 0;
}
#endif
0