結果

問題 No.3018 目隠し宝探し
ユーザー bolero
提出日時 2025-01-25 14:03:01
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,031 bytes
コンパイル時間 5,678 ms
コンパイル使用メモリ 332,880 KB
実行使用メモリ 25,972 KB
平均クエリ数 2.59
最終ジャッジ日時 2025-01-25 23:06:02
合計ジャッジ時間 8,993 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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

// 可変引数repマクロ https://trap.jp/post/1224/
#define rep1(a) for (long long i = 0; i < (long long)a; i++)
#define rep2(i, a) for (long long i = 0; i < (long long)a; i++)
#define rep3(i, a, b) for (long long i = (long long)a; i <= (long long)b; i++)
#define rep4(i, a, b, c) for (long long i = (long long)a; i <= (long long)b; i += (long long)c)
#define overload4(a, b, c, d, e, ...) e
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)

#define printYesNo(is_ok) puts(is_ok ? "Possible" : "Impossible")
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(RALL(v))
#define REVERSE(v) reverse(ALL(v))

template <class T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
template <class T>
using pq_des = priority_queue<T>;

template <typename T>
void printlnVector(T v)
{
  for (auto n : v)
  {
    cout << n << endl;
  }
}

template <typename T>
void printVector(T v)
{
  for (auto n : v)
  {
    cout << n << " ";
  }
  cout << endl;
}

int main()
{
  long long H, W;
  cin >> H >> W;

  vector<vector<bool>> is_ans(H, vector<bool>(W, true));

  while (true)
  {
    int h = rand() % H, w = rand() % W;
    cout << "? " << h + 1 << " " << w + 1 << endl;
    flush(cout);
    long long d;
    cin >> d;

    if (d == -1)
    {
      break;
    }

    rep(hh, H) rep(ww, W)
    {
      long long dist = (hh - h) * (hh - h) + (ww - w) * (ww - w);
      if (dist != d)
      {
        is_ans[hh][ww] = false;
      }
    }

    bool ok = false;
    pair<int, int> ans = {-1, -1};
    rep(hh, H) rep(ww, W)
    {
      if (is_ans[hh][ww])
      {
        if (ans == pair<int, int>{-1, -1})
        {
          ans = {hh + 1, ww + 1};
          ok = true;
        }
        else
        {
          ok = false;
        }
      }
    }

    if (ok)
    {
      cout << "! " << ans.first << " " << ans.second << endl;
      break;
    }
  }

  return 0;
}
0