結果
問題 |
No.2354 Poor Sight in Winter
|
ユーザー |
|
提出日時 | 2023-06-16 22:38:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,831 ms / 2,000 ms |
コード長 | 1,817 bytes |
コンパイル時間 | 1,760 ms |
コンパイル使用メモリ | 138,116 KB |
最終ジャッジ日時 | 2025-02-14 06:42:44 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:56:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 56 | scanf("%d%d", &n, &k); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:57:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 57 | scanf("%d%d%d%d", &vp[0].first, &vp[0].second, &vp[n + 1].first, &vp[n + 1].second); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:59:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 59 | scanf("%d%d", &vp[i].first, &vp[i].second); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #include <cstdlib> #include <cctype> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include <string> #include <iostream> #include <sstream> #include <map> #include <set> #include <queue> #include <stack> #include <fstream> #include <numeric> #include <iomanip> #include <bitset> #include <list> #include <stdexcept> #include <functional> #include <utility> #include <ctime> #include <cassert> using namespace std; typedef long long LL; typedef unsigned long long ULL; #define MEM(a,b) memset((a),(b),sizeof(a)) const LL INF = 1e9 + 7; const int N = 5e2 + 10; int a[N][N]; int d[N][N]; pair<int, int> vp[N]; void floyd(int n) { for (int k = 0; k <= n; k++) { for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) a[i][j] = min(a[i][j], a[i][k] + a[k][j]); } } } inline int dis(int i, int j) { return abs(vp[i].first - vp[j].first) + abs(vp[i].second - vp[j].second); } int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); int n, k; scanf("%d%d", &n, &k); scanf("%d%d%d%d", &vp[0].first, &vp[0].second, &vp[n + 1].first, &vp[n + 1].second); for (int i = 1; i <= n; i++) scanf("%d%d", &vp[i].first, &vp[i].second); n++; for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) d[i][j] = dis(i, j); } int l = 1, r = dis(0, n); int ans = r; while (l <= r) { int mid = (l + r) / 2; for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { int d = ::d[i][j] - mid; d = max(0, d); a[i][j] = (d + mid - 1) / (mid); } } floyd(n); if (a[0][n] <= k) ans = mid, r = mid - 1; else l = mid + 1; } printf("%d\n", ans); return 0; }