結果

問題 No.3520 L1等距離点
コンテスト
ユーザー yamate11
提出日時 2026-05-01 21:57:53
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 1,265 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,278 ms
コンパイル使用メモリ 330,804 KB
実行使用メモリ 30,320 KB
平均クエリ数 4.83
最終ジャッジ日時 2026-05-01 21:58:00
合計ジャッジ時間 5,833 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <cassert>
using namespace std;
using ll = long long int;
using u64 = unsigned long long;
using pll = pair<ll, ll>;
// #include <atcoder/all>
// using namespace atcoder;
#define REP(i, a, b) for (ll i = (a); i < (b); i++)
#define REPrev(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(coll) (coll).begin(), (coll).end()
#define SIZE(v) ((ll)((v).size()))
#define REPOUT(i, a, b, exp, sep) REP(i, (a), (b)) cout << (exp) << (i + 1 == (b) ? "" : (sep)); cout << "\n"

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  auto ask = [&](ll t) -> pll {
    cout << "? " << t << endl;
    ll x, y; cin >> x >> y;
    return pll(x, y);
  };

  auto report = [&](ll t) -> void {
    cout << "! " << t << endl;
  };


  ll T, x0, y0, xt, yt; cin >> T >> x0 >> y0 >> xt >> yt;
  
  ll tL = 0, tH = T;
  while (true) {
    if (tH == tL + 1) {
      report(tL);
      return 0;
    }
    ll tM = (tL + tH) / 2;
    auto [xM, yM] = ask(tM);
    ll dL = abs(x0 - xM) + abs(y0 - yM);
    ll dH = abs(xt - xM) + abs(yt - yM);
    if (dL == dH) {
      report(tM);
      return 0;
    }
    if (dL > dH) tH = tM;
    else tL = tM;
  }


  return 0;
}

0