結果
問題 |
No.3161 Find Presents
|
ユーザー |
|
提出日時 | 2025-05-06 19:54:19 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 233 ms / 4,000 ms |
コード長 | 892 bytes |
コンパイル時間 | 3,335 ms |
コンパイル使用メモリ | 276,872 KB |
実行使用メモリ | 26,344 KB |
平均クエリ数 | 3406.01 |
最終ジャッジ日時 | 2025-05-06 19:54:39 |
合計ジャッジ時間 | 18,149 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 80 |
ソースコード
#include <bits/stdc++.h> using namespace std; vector<pair<int, int>> presents; bool ask(int l, int r, int d, int u){ cout << "? " << l << " " << r << " " << d << " " << u << endl; int res; cin >> res; assert(res != -1); return res; } void dfs(int l, int r, int d, int u){ if(l == r){ if(d == u){ presents.emplace_back(make_pair(l, d)); } else{ int m = (d + u) / 2; if(ask(l, r, d, m)) dfs(l, r, d, m); if(ask(l, r, m + 1, u)) dfs(l, r, m + 1, u); } } else{ int m = (l + r) / 2; if(ask(l, m, d, u)) dfs(l, m, d, u); if(ask(m + 1, r, d, u)) dfs(m + 1, r, d, u); } } int main(){ dfs(0, 1'000'000, 0, 1'000'000); cout << "! " << presents.size() << endl; for(auto [x,y]:presents){ cout << x << " " << y << endl; } return 0; }