結果

問題 No.355 数当てゲーム(2)
ユーザー MisterMister
提出日時 2020-05-29 17:04:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 988 bytes
コンパイル時間 4,565 ms
コンパイル使用メモリ 80,684 KB
最終ジャッジ日時 2025-01-10 16:13:33
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 WA * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

int query(const std::vector<int>& xs) {
    for (auto x : xs) std::cout << x << " ";
    std::cout << std::endl;

    int a, b;
    std::cin >> a >> b;
    if (a == 4) std::exit(0);
    return a + b;
}

void solve() {
    std::vector<int> xs;

    std::vector<int> ys(4);
    std::iota(ys.begin(), ys.end(), 0);
    int b = query(ys);

    for (int d = 4; d <= 9; ++d) {
        ys.back() = d;
        if (query(ys) > b) xs.push_back(d);
    }

    std::iota(ys.begin(), ys.end(), 6);
    b = query(ys);
    for (int d = 0; d < 6; ++d) {
        ys.front() = d;
        if (query(ys) > b) xs.push_back(d);
    }

    std::sort(xs.begin(), xs.end());
    xs.erase(std::unique(xs.begin(), xs.end()), xs.end());

    do {
        query(xs);
    } while (std::next_permutation(xs.begin(), xs.end()));
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0