結果

問題 No.2502 Optimization in the Dark
ユーザー suisensuisen
提出日時 2023-01-12 15:49:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,418 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 69,896 KB
実行使用メモリ 24,372 KB
平均クエリ数 4.00
最終ジャッジ日時 2023-10-13 20:30:06
合計ジャッジ時間 5,011 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
23,400 KB
testcase_01 AC 26 ms
23,292 KB
testcase_02 AC 26 ms
23,496 KB
testcase_03 AC 27 ms
23,904 KB
testcase_04 AC 25 ms
23,832 KB
testcase_05 AC 26 ms
24,372 KB
testcase_06 AC 26 ms
23,688 KB
testcase_07 AC 26 ms
23,532 KB
testcase_08 AC 26 ms
23,292 KB
testcase_09 AC 26 ms
23,376 KB
testcase_10 AC 26 ms
23,652 KB
testcase_11 AC 27 ms
23,868 KB
testcase_12 AC 27 ms
23,868 KB
testcase_13 AC 26 ms
23,832 KB
testcase_14 AC 26 ms
23,532 KB
testcase_15 AC 26 ms
24,132 KB
testcase_16 AC 26 ms
24,144 KB
testcase_17 AC 25 ms
23,556 KB
testcase_18 AC 26 ms
23,628 KB
testcase_19 AC 27 ms
23,628 KB
testcase_20 AC 26 ms
23,532 KB
testcase_21 AC 26 ms
24,012 KB
testcase_22 AC 26 ms
23,880 KB
testcase_23 AC 26 ms
23,412 KB
testcase_24 AC 26 ms
23,388 KB
testcase_25 AC 25 ms
23,856 KB
testcase_26 AC 25 ms
23,424 KB
testcase_27 AC 26 ms
24,228 KB
testcase_28 AC 26 ms
23,544 KB
testcase_29 AC 25 ms
24,240 KB
testcase_30 AC 26 ms
24,216 KB
testcase_31 AC 25 ms
23,292 KB
testcase_32 AC 26 ms
23,532 KB
testcase_33 AC 26 ms
23,292 KB
testcase_34 AC 24 ms
24,012 KB
testcase_35 AC 26 ms
23,688 KB
testcase_36 AC 26 ms
24,132 KB
testcase_37 AC 26 ms
24,300 KB
testcase_38 AC 27 ms
23,484 KB
testcase_39 AC 25 ms
23,844 KB
testcase_40 AC 26 ms
23,520 KB
testcase_41 AC 26 ms
23,292 KB
testcase_42 AC 25 ms
23,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <iostream>

bool query(int i, int x, int j, int y) {
    std::cout << "? " << i << ' ' << x << ' ' << j << ' ' << y << '\n', std::cout.flush();
    std::string response;
    std::cin >> response;
    if (response == "Yes") {
        return true;
    } else if (response == "No") {
        return false;
    } else {
        assert(false);
    }
}
void output_answer(int n, int i1, int j1, int i2, int j2, int i3, int j3) {
    std::cout << "!";
    for (int i = 0; i < n; ++i) std::cout << ' ' << i1 << ' ' << j1;
    for (int i = 0; i < n; ++i) std::cout << ' ' << i2 << ' ' << j2;
    for (int i = 0; i < n; ++i) std::cout << ' ' << i3 << ' ' << j3;
    std::cout << '\n', std::cout.flush();
}

int main() {
    int n;
    std::cin >> n;

    int i3, j3, i2, j2, i1, j1;

    bool q1 = query(2, 2 * n, 3, 2 * n);
    if (q1) {
        bool q2 = query(1, 2 * n, 3, 2 * n);
        if (q2) {
            i3 = 1, j3 = 2;
        } else {
            i3 = 2, j3 = 3;
        }
    } else {
        bool q2 = query(1, 2 * n, 2, 2 * n);
        if (q2) {
            i3 = 1, j3 = 3;
        } else {
            i3 = 2, j3 = 3;
        }
    }

    std::cerr << i3 << ", " << j3 << std::endl;

    i2 = i3 ^ j3;
    bool q3 = query(i3, n, j3, n);
    if (q3) {
        j2 = i3;
    } else {
        j2 = j3;
    }
    i1 = i2, j1 = j2 ^ i3 ^ j3;

    output_answer(n, i1, j1, i2, j2, i3, j3);
}
0