提出 #54595203


ソースコード 拡げる

#include <cmath>
#include <iostream>
#include <set>

int main() {
    int n, m;
    std::cin >> n >> m;
    std::set<int> flavour_sales;

    int t = 0;
    for (int i = 0; i < m; ++i) {
        t += std::pow(2, i);
    }

    char c;

    for (int i = 0; i < n; ++i) {
        int s = 0;
        for (int j = 0; j < m; ++j) {
            std::cin >> c;
            if (c == 'x') {
                continue;
            }
            s |= (1<<(m-j-1));
        }

        if (s == t) {
            std::cout << 1 << std::endl;
            return 0;
        }

        flavour_sales.insert(s);
    }

    std::set<int> prev_combinations = flavour_sales, current_combinations;

    for (int i = 2; i <= m; ++i) {
        for (auto p : prev_combinations) {
            for (auto s : flavour_sales) {
                current_combinations.insert(p|s);
            }
        }

        if (current_combinations.find(t) != current_combinations.end()) {
            std::cout << i << std::endl;
            return 0;
        }

        prev_combinations = current_combinations;
        current_combinations = {};
    }
}

提出情報

提出日時
問題 C - Popcorn
ユーザ sglre6355
言語 C++ 20 (gcc 12.2)
得点 300
コード長 1165 Byte
結果 AC
実行時間 3 ms
メモリ 3864 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 28
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 02_handmade_00.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3780 KiB
00_sample_01.txt AC 1 ms 3768 KiB
00_sample_02.txt AC 1 ms 3632 KiB
01_random_00.txt AC 1 ms 3732 KiB
01_random_01.txt AC 1 ms 3796 KiB
01_random_02.txt AC 1 ms 3724 KiB
01_random_03.txt AC 1 ms 3740 KiB
01_random_04.txt AC 1 ms 3612 KiB
01_random_05.txt AC 1 ms 3692 KiB
01_random_06.txt AC 1 ms 3736 KiB
01_random_07.txt AC 1 ms 3696 KiB
01_random_08.txt AC 1 ms 3684 KiB
01_random_09.txt AC 1 ms 3704 KiB
01_random_10.txt AC 1 ms 3740 KiB
01_random_11.txt AC 1 ms 3712 KiB
01_random_12.txt AC 1 ms 3684 KiB
01_random_13.txt AC 1 ms 3596 KiB
01_random_14.txt AC 1 ms 3636 KiB
01_random_15.txt AC 1 ms 3708 KiB
01_random_16.txt AC 1 ms 3596 KiB
01_random_17.txt AC 1 ms 3688 KiB
01_random_18.txt AC 1 ms 3676 KiB
01_random_19.txt AC 1 ms 3688 KiB
01_random_20.txt AC 1 ms 3688 KiB
02_handmade_00.txt AC 3 ms 3864 KiB
02_handmade_01.txt AC 1 ms 3624 KiB
02_handmade_02.txt AC 1 ms 3596 KiB
02_handmade_03.txt AC 1 ms 3536 KiB