結果
| 問題 |
No.168 ものさし
|
| コンテスト | |
| ユーザー |
horizon4096
|
| 提出日時 | 2017-12-28 13:24:12 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 1,328 bytes |
| コンパイル時間 | 694 ms |
| コンパイル使用メモリ | 77,040 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 07:22:25 |
| 合計ジャッジ時間 | 1,604 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:61:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
61 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:63:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
63 | scanf("%d%d", &X[i], &Y[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
const int iinf = 1 << 29;
const long long linf = 1ll << 61;
#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))
int N;
int X[1001];
int Y[1001];
bool visit[1001];
bool C(int d)
{
d *= 10;
fill(visit, visit + 1001, false);
queue<int> q;
q.push(1);
visit[1] = true;
while (!q.empty()) {
int v = q.front();
q.pop();
if (v == N) return true;
for (int i = 1; i <= N; i++) {
if (visit[i]) continue;
ll x = X[v] - X[i];
ll y = Y[v] - Y[i];
ll dist = x * x + y * y;
if (dist <= (ll)d * (ll)d) {
visit[i] = true;
q.push(i);
}
}
}
return false;
}
int main(int argc, char* argv[])
{
scanf("%d", &N);
for (int i = 1; i <= N; i++) {
scanf("%d%d", &X[i], &Y[i]);
}
int l = 0, u = (int)(pow(10, 9) * pow(2, 0.5) / 10) + 1;
while (l < u) {
int mid = (l + u) / 2;
if (C(mid)) u = mid;
else l = mid + 1;
}
printf("%d\n", u * 10);
return 0;
}
horizon4096