結果

問題 No.168 ものさし
ユーザー mizunomidorimizunomidori
提出日時 2016-07-04 00:47:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 1,420 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 78,344 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 21:01:40
合計ジャッジ時間 1,859 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 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 3 ms
4,380 KB
testcase_11 AC 11 ms
4,380 KB
testcase_12 AC 29 ms
4,376 KB
testcase_13 AC 33 ms
4,376 KB
testcase_14 AC 30 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 39 ms
4,380 KB
testcase_20 AC 26 ms
4,380 KB
testcase_21 AC 63 ms
4,376 KB
testcase_22 AC 31 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>

#define N_MAX 1000

using namespace std;

typedef long long ll;

int N;
ll X[N_MAX];
ll Y[N_MAX];
bool used[N_MAX];

// 長さ10*lのものさしを用いてP_0からP_(N-1)までつなげられるときに限りtrueを返す.
bool can_reach(ll l)
{
    fill(used, used + N, false);
    queue<int> q;
    q.push(0);
    used[0] = true;
    while (!q.empty()) {
        int p = q.front();
        q.pop();
        for (int i = 0; i < N; i++) {
            if (!used[i]) {
                ll dX = X[p] - X[i], dY = Y[p] - Y[i];
                if (dX * dX + dY * dY <= 100 * l * l) {
                    q.push(i);
                    used[i] = true;
                }
            }
        }
    }
    return used[N - 1];
}

int main(void)
{
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
    }
    int low = 0, high = 400000000;
    // (low, high]の中に答えがある.
    while (high - low > 1) {
        int mid = (low + high) / 2;
        if (can_reach(mid)) {
            high = mid;
        } else {
            low = mid;
        }
    }
    cout << 10 * high << endl;
    return 0;
}
0