結果

問題 No.3018 目隠し宝探し
ユーザー a01sa01to
提出日時 2025-01-29 00:38:07
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,013 bytes
コンパイル時間 3,316 ms
コンパイル使用メモリ 273,424 KB
実行使用メモリ 26,228 KB
平均クエリ数 2.68
最終ジャッジ日時 2025-01-29 00:38:16
合計ジャッジ時間 6,556 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

inline ll dist(ll x1, ll y1, ll x2, ll y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}

int main() {
  int h, w;
  cin >> h >> w;
  if (h == 1 && w == 1) {
    cout << "! 1 1" << endl;
    return 0;
  }
  if (h == 1 || w == 1) {
    cout << "? 1 1" << endl;
    int x;
    cin >> x;
    if (h != 1) {
      cout << "! " << x + 1 << " 1" << endl;
    }
    else {
      cout << "! 1 " << x + 1 << endl;
    }
    return 0;
  }
  ll x, y;
  cout << "? 1 1" << endl;
  cin >> x;
  cout << "? 1 " << w << endl;
  cin >> y;
  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      if (dist(i, j, 1, 1) == x && dist(i, j, 1, w) == y) {
        cout << "! " << i << ' ' << j << endl;
        return 0;
      }
    }
  }
  assert(false);
  return 0;
}
0