結果

問題 No.168 ものさし
ユーザー ushitora_anqouushitora_anqou
提出日時 2017-12-26 21:59:14
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,256 bytes
コンパイル時間 1,414 ms
コンパイル使用メモリ 143,936 KB
実行使用メモリ 12,036 KB
最終ジャッジ日時 2023-08-22 22:02:55
合計ジャッジ時間 8,495 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define mp make_pair
#define P pair
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define cbuf(buf, init) memset(buf, init, sizeof(buf))
#define modp(x, y) (((y) + (x) % (y)) % (y))
#define divd(x, y) (static_cast<double>(x) / static_cast<double>(y))
#define sq(x) (x) * (x)

ll N, X[2000], Y[2000];
bool used[2000];

bool dfs(ll now, ll l)
{
    if (now == N - 1) return true;
    used[now] = true;
    rep(i, 0, N)
    {
        if (used[i] || sq(X[now] - X[i]) + sq(Y[now] - Y[i]) > sq(l)) continue;
        if (dfs(i, l)) {
            used[now] = false;
            return true;
        }
    }
    used[now] = false;
    return false;
}

bool C(ll l)
{
    cbuf(used, false);
    return dfs(0, l);
}

int main()
{
    //
    cin >> N;
    rep(i, 0, N) { cin >> X[i] >> Y[i]; }

    ll lb = 0, ub = 2E9;
    while (ub - lb > 1) {
        ll mid = (lb + ub) / 2;
        if (C(mid))
            ub = mid;
        else
            lb = mid;
    }
    cout << ((ub + 5) / 10 * 10) << endl;
}
0