結果

問題 No.24 数当てゲーム
ユーザー H3PO4H3PO4
提出日時 2023-02-20 10:18:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 844 bytes
コンパイル時間 844 ms
コンパイル使用メモリ 81,720 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-28 09:30:38
合計ジャッジ時間 1,489 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

bool is_possible(int &x,
                 std::vector<std::pair<std::vector<int>, bool>> &data) {
    for (const auto &[V, R]: data) {
        bool exist = std::any_of(V.begin(), V.end(), [&x](int v) { return v == x; });
        if (exist != R) { return false; }
    }
    return true;
}

int main() {
    int N;
    std::cin >> N;
    std::vector<std::pair<std::vector<int>, bool>> data(N);
    for (int i = 0; i < N; i++) {
        std::vector<int> V(4);
        for (int j = 0; j < 4; j++) {
            std::cin >> V.at(j);
        }
        std::string R;
        std::cin >> R;
        bool flag = (R == "YES");
        data.at(i) = {V, flag};
    }
    for (int x = 0; x < 10; x++) {
        if (is_possible(x, data)){
            std::cout << x << std::endl;
        }
    }
}
0