結果
問題 | No.2354 Poor Sight in Winter |
ユーザー | 👑 Nachia |
提出日時 | 2023-06-16 22:30:58 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 81 ms / 2,000 ms |
コード長 | 1,313 bytes |
コンパイル時間 | 807 ms |
コンパイル使用メモリ | 85,972 KB |
実行使用メモリ | 7,228 KB |
最終ジャッジ日時 | 2024-06-24 15:06:52 |
合計ジャッジ時間 | 2,348 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <atcoder/modint> using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; int main(){ int N; cin >> N; N+=2; int M; cin >> M; vector<i64> X(N), Y(N); rep(i,N) cin >> X[i] >> Y[i]; vector<vector<i64>> dist(N, vector<i64>(N)); rep(i,N) rep(j,N) dist[i][j] = abs(X[i]-X[j]) + abs(Y[i]-Y[j]); int ng = 0, ok = dist[0][1]; while(abs(ng - ok) > 1){ i64 K = (ng + ok) / 2; auto d = dist; for(auto& dd : d) for(auto& e : dd) e = max<i64>((e + K - 1) / K - 1, 0); vector<i64> ds(N, INF); ds[0] = 0; vector<int> vis(N, 0); rep(i,N){ int x = -1; rep(j,N) if(vis[j] == 0) if(x < 0 || ds[x] > ds[j]) x = j; rep(j,N) ds[j] = min(ds[j], ds[x] + d[x][j]); vis[x] = 1; } (ds[1] <= M ? ok : ng) = K; } cout << ok << endl; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;