結果

問題 No.2669 Generalized Hitting Set
ユーザー suisensuisen
提出日時 2023-09-21 02:30:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,136 bytes
コンパイル時間 858 ms
コンパイル使用メモリ 85,576 KB
実行使用メモリ 6,856 KB
最終ジャッジ日時 2024-01-16 20:53:12
合計ジャッジ時間 4,410 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,676 KB
testcase_02 WA -
testcase_03 AC 21 ms
6,676 KB
testcase_04 AC 18 ms
6,676 KB
testcase_05 AC 17 ms
6,676 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 22 ms
6,676 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 30 ms
6,676 KB
testcase_13 WA -
testcase_14 AC 2 ms
6,676 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
6,676 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 2 ms
6,676 KB
testcase_37 WA -
testcase_38 AC 1 ms
6,676 KB
testcase_39 AC 65 ms
6,856 KB
testcase_40 AC 59 ms
6,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// WA: greedy (1)

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

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    size_t n, m, k;
    std::cin >> n >> m >> k;

    std::vector<uint> s(m);
    for (size_t i = 0; i < m; ++i) {
        std::string si;
        std::cin >> si;
        for (size_t j = 0; j < n; ++j) {
            s[i] |= (si[j] - '0') << j;
        }
    }

    std::vector<std::pair<size_t, size_t>> hist(n);
    for (size_t i = 0; i < n; ++i) {
        hist[i] = { 0, i };
    }
    for (uint e : s) {
        for (size_t i = 0; i < n; ++i) if ((e >> i) & 1) ++hist[i].first;
    }
    std::sort(hist.begin(), hist.end(), std::greater<>());

    std::vector<size_t> g(m + 1, n + 1);

    size_t ok = 0;
    uint t = 0, ct = 0;
    while (ok < m) {
        t |= 1 << hist[ct].second;
        ++ct;

        ok = 0;
        for (uint e : s) ok += __builtin_popcount(t & e) >= k;
        g[ok] = ct;
    }

    for (size_t p = m; p; --p) {
        g[p - 1] = std::min(g[p - 1], g[p]);
    }

    for (size_t p = 1; p <= m; ++p) {
        std::cout << g[p] << '\n';
    }
}
0