結果
問題 | No.168 ものさし |
ユーザー |
![]() |
提出日時 | 2017-12-28 09:53:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 911 bytes |
コンパイル時間 | 1,311 ms |
コンパイル使用メモリ | 158,244 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 07:22:12 |
合計ジャッジ時間 | 2,311 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; }