結果
| 問題 | No.168 ものさし |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-16 18:23:26 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 910 bytes |
| 記録 | |
| コンパイル時間 | 2,108 ms |
| コンパイル使用メモリ | 209,632 KB |
| 実行使用メモリ | 6,144 KB |
| 最終ジャッジ日時 | 2026-03-16 18:23:37 |
| 合計ジャッジ時間 | 3,278 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define cbuf(buf, init) memset(buf, init, sizeof(buf))
#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)) {
return true;
}
}
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;
mid = mid / 10 * 10;
if (mid == lb) break;
if (C(mid))
ub = mid;
else
lb = mid;
}
cout << ub << endl;
}