結果

問題 No.3161 Find Presents
ユーザー Cafe1942
提出日時 2025-05-23 20:37:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,247 bytes
コンパイル時間 1,317 ms
コンパイル使用メモリ 119,312 KB
実行使用メモリ 26,216 KB
平均クエリ数 3209.84
最終ジャッジ日時 2025-05-23 20:38:03
合計ジャッジ時間 16,377 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22 WA * 58
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>//小数点出力用
//cout << fixed << setprecision(10) << ans;
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
using ll = long long;
using namespace std;
#define modP7 1'000'000'007
#define modP 998244353
bool chkrng0idx(int pos, int sup) { return (0 <= pos && pos < sup); }
int clk4(int num) { return (num - 2) * (num % 2); }
void yn(bool tf) { cout << (tf ? "Yes\n" : "No\n"); }
#define top() front().first
int main() {
    queue < pair < pair<pair<int, int>, pair<int, int>>, bool>> S;
    S.push({ { {0,1000000},{0,500000} },0 });
    S.push({ { {0,1000000},{500001,1000000} },0 });
    vector<pair<int, int >> ans;
    while (!S.empty()) {
        cout << "? " << S.top().first.first << " " << S.top().first.second << " " << S.top().second.first << " " << S.top().second.second << endl;
        int r;
        cin >> r;
        if (r == 1) {
            if (S.top().first.first == S.top().first.second && S.top().second.first == S.top().second.second) {
                ans.push_back({ S.top().first.first ,S.top().second.first });
            }
            else {
                if (S.front().second == 1) {
                    S.push({ { {S.top().first.first, S.top().first.second},{S.top().second.first,(S.top().second.first + S.top().second.second) / 2} },0 });
                    S.push({ {{S.top().first.first, S.top().first.second},{(S.top().second.first + S.top().second.second) / 2 + 1, S.top().second.second} },0 });


                }
                else {
                    S.push({ { {S.top().first.first,(S.top().first.first + S.top().first.second) / 2},{S.top().second.first,S.top().second.second} },1 });
                    S.push({ {{(S.top().first.first + S.top().first.second) / 2 + 1,S.top().first.second},{S.top().second.first,S.top().second.second} },1 });

                }
            }
        }
        else if (r == -1) {
            cout << "death";
            return 0;
        }
        S.pop();
    }
    cout << "! " << ans.size() << endl;
    for (int i = 0;i < ans.size();i++) {
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}
0