結果

問題 No.2354 Poor Sight in Winter
ユーザー Kyo_s_sKyo_s_s
提出日時 2023-06-17 00:14:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,178 bytes
コンパイル時間 2,415 ms
コンパイル使用メモリ 206,664 KB
実行使用メモリ 9,696 KB
最終ジャッジ日時 2023-09-06 23:19:11
合計ジャッジ時間 6,466 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,768 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

using ll = long long;
ll INF = 1LL << 58;
#define pb push_back

int main() {
  
  ll N, K; cin >> N >> K;
  ll sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy;
  vector<ll> X(N), Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }

  // N -> s, N + 1 -> g
  X.pb(sx); X.pb(gx);
  Y.pb(sy); Y.pb(gy);

  auto check = [&](ll P) -> bool {
    vector cost(N + 2, vector<ll>(N + 2));
    for (int i = 0; i < N + 2; i++) {
      for (int j = 0; j < N + 2; j++) {
        ll m = abs(X[i] - X[j]) + abs(Y[i] - Y[j]);
        if (m == 0) m++;
        cost[i][j] = (m - 1) / P;
      }
    }
    
    vector<ll> dist(N + 2, INF);
    dist[N] = 0;

    for (int n = 0; n < N + 10; n++) {
      vector<ll> tsid(N + 2, INF);
      for (int i = 0; i < N + 2; i++) {
        for (int j = 0; j < N + 2; j++) {
          tsid[i] = min(tsid[i], dist[j] + cost[j][i]);
        }
      }
      dist = tsid;
    }
    
    return dist[N + 1] <= K;
  };

  ll ok = 101010, ng = 0;
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (check(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << ok << endl;
  
}
0