結果
問題 | No.168 ものさし |
ユーザー |
![]() |
提出日時 | 2017-12-28 13:17:37 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 184 ms / 2,000 ms |
コード長 | 1,465 bytes |
コンパイル時間 | 732 ms |
コンパイル使用メモリ | 77,280 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2024-12-24 07:22:18 |
合計ジャッジ時間 | 2,376 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’: main.cpp:59:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 59 | scanf("%d", &N); | ~~~~~^~~~~~~~~~ main.cpp:61:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 61 | 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]; ll dist[1001][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; if (dist[v][i] <= (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]); } for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { int x = X[j] - X[i]; int y = Y[j] - Y[i]; dist[i][j] = (ll)x * (ll)x + (ll)y * (ll)y; } } int l = 0, u = (int)(pow(10, 9) * pow(2, 0.5) / 10) + 1; for (int i = 0; i < 100; i++) { int mid = (l + u) / 2; if (C(mid)) u = mid; else l = mid + 1; } printf("%d\n", u * 10); return 0; }