結果
| 問題 | No.3161 Find Presents | 
| コンテスト | |
| ユーザー |  jastaway | 
| 提出日時 | 2025-05-04 16:28:17 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 253 ms / 4,000 ms | 
| コード長 | 996 bytes | 
| コンパイル時間 | 3,395 ms | 
| コンパイル使用メモリ | 279,552 KB | 
| 実行使用メモリ | 26,216 KB | 
| 平均クエリ数 | 3406.26 | 
| 最終ジャッジ日時 | 2025-05-05 21:10:27 | 
| 合計ジャッジ時間 | 18,632 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 80 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
vector<int> Xs;
vector<pair<int, int>> ans;
const int MX = 1000000;
bool ask(int xl, int xr, int yl, int yr)
{
    cout << "? " << xl << " " << xr << " " << yl << " " << yr << endl;
    int ret;
    cin >> ret;
    assert(ret == 0 || ret == 1);
    return ret == 1;
}
void findx(int l, int r)
{
    if(l + 1 == r)
    {
        Xs.push_back(l);
        return;
    }
    int m = (l + r)/2;
    if(ask(l, m - 1, 0, MX)) findx(l, m);
    if(ask(m, r - 1, 0, MX)) findx(m, r);
    return;
}
void findy(int l, int r, int x)
{
    if(l + 1 == r)
    {
        ans.emplace_back(x, l);
        return;
    }
    int m = (l + r)/2;
    if(ask(x, x, l, m - 1)) findy(l, m, x);
    if(ask(x, x, m, r - 1)) findy(m, r, x);
}
int main()
{
    findx(0, MX + 1);
    for(int x : Xs)
    {
        findy(0, MX + 1, x);
    }
    int N = ans.size();
    cout << "! " << N << endl;
    for(auto [x, y] : ans)
    {
        cout << x << " " << y << endl;
    }
}
            
            
            
        