結果

問題 No.3161 Find Presents
ユーザー Kude
提出日時 2025-05-23 19:58:25
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 270 ms / 4,000 ms
コード長 1,595 bytes
コンパイル時間 4,445 ms
コンパイル使用メモリ 297,816 KB
実行使用メモリ 25,960 KB
平均クエリ数 3401.61
最終ジャッジ日時 2025-05-23 19:58:45
合計ジャッジ時間 17,765 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 80
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<P> ans;
  auto ask = [](int xl, int xr, int yl, int yr) {
    cout << "? " << xl << ' ' << xr - 1 << ' ' << yl << ' ' << yr - 1 << endl;
    int res;
    cin >> res;
    assert(res >= 0);
    return res;
  };
  auto dfs = [&](auto&& self, int xl, int xr, int yl, int yr) -> void {
    if (!ask(xl, xr, yl, yr)) return;
    if (xl + 1 == xr && yl + 1 == yr) {
      ans.emplace_back(xl, yl);
      return;
    }
    if (xr - xl > yr - yl) {
      int xc = (xl + xr) / 2;
      self(self, xl, xc, yl, yr);
      self(self, xc, xr, yl, yr);
    } else {
      int yc = (yl + yr) / 2;
      self(self, xl, xr, yl, yc);
      self(self, xl, xr, yc, yr);
    }
  };
  dfs(dfs, 0, 1000001, 0, 1000001);
  cout << "! " << ssize(ans) << '\n';
  for (auto [x, y] : ans) cout << x << ' ' << y << '\n';
}
0