結果

問題 No.2669 Generalized Hitting Set
ユーザー 👑 hos.lyrichos.lyric
提出日時 2024-03-08 21:57:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,533 ms / 4,000 ms
コード長 2,632 bytes
コンパイル時間 1,093 ms
コンパイル使用メモリ 114,324 KB
実行使用メモリ 141,824 KB
最終ジャッジ日時 2024-03-08 21:57:34
合計ジャッジ時間 18,821 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 32 ms
8,548 KB
testcase_04 AC 28 ms
8,548 KB
testcase_05 AC 24 ms
8,548 KB
testcase_06 AC 41 ms
10,596 KB
testcase_07 AC 8 ms
6,676 KB
testcase_08 AC 11 ms
6,676 KB
testcase_09 AC 29 ms
8,548 KB
testcase_10 AC 17 ms
6,676 KB
testcase_11 AC 9 ms
6,676 KB
testcase_12 AC 37 ms
8,548 KB
testcase_13 AC 1,398 ms
134,504 KB
testcase_14 AC 142 ms
19,816 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 33 ms
7,528 KB
testcase_17 AC 140 ms
19,816 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 17 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 32 ms
7,528 KB
testcase_22 AC 9 ms
6,676 KB
testcase_23 AC 64 ms
10,852 KB
testcase_24 AC 40 ms
8,548 KB
testcase_25 AC 86 ms
14,336 KB
testcase_26 AC 1,409 ms
137,216 KB
testcase_27 AC 38 ms
9,316 KB
testcase_28 AC 1,533 ms
141,824 KB
testcase_29 AC 1,510 ms
141,824 KB
testcase_30 AC 1,507 ms
141,824 KB
testcase_31 AC 1,528 ms
141,824 KB
testcase_32 AC 1,500 ms
141,824 KB
testcase_33 AC 69 ms
12,388 KB
testcase_34 AC 54 ms
10,596 KB
testcase_35 AC 370 ms
40,960 KB
testcase_36 AC 2 ms
6,676 KB
testcase_37 AC 64 ms
11,624 KB
testcase_38 AC 6 ms
6,676 KB
testcase_39 AC 1,504 ms
141,824 KB
testcase_40 AC 1,496 ms
141,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


int N, M, K;
char S[300'010][25];

Int bn[25][25], pie[25];

int main() {
  for (; ~scanf("%d%d%d", &N, &M, &K); ) {
    for (int i = 0; i < M; ++i) {
      scanf("%s", S[i]);
    }
    
    for (int n = 0; n <= N; ++n) {
      bn[n][0] = bn[n][n] = 1;
      for (int k = 1; k < n; ++k) {
        bn[n][k] = bn[n - 1][k - 1] + bn[n - 1][k];
      }
    }
    for (int n = 0; n <= N; ++n) {
      pie[n] = (n >= K) ? 1 : 0;
      for (int k = 0; k < n; ++k) {
        pie[n] -= bn[n][k] * pie[k];
      }
    }
cerr<<"pie = ";pv(pie,pie+(N+1));
    
    vector<Int> fs(1 << N, 0);
    for (int i = 0; i < M; ++i) {
      int p = 0;
      for (int e = 0; e < N; ++e) p |= (S[i][e] - '0') << e;
      ++fs[p];
    }
    for (int e = 0; e < N; ++e) {
      for (int p = 0; p < 1 << N; ++p) if (!(p & 1 << e)) {
        fs[p] += fs[p | 1 << e];
      }
    }
    for (int p = 0; p < 1 << N; ++p) {
      fs[p] *= pie[__builtin_popcount(p)];
    }
    for (int e = 0; e < N; ++e) {
      for (int p = 0; p < 1 << N; ++p) if (!(p & 1 << e)) {
        fs[p | 1 << e] += fs[p];
      }
    }
    vector<Int> mxs(N + 1, 0);
    for (int p = 0; p < 1 << N; ++p) {
      chmax(mxs[__builtin_popcount(p)], fs[p]);
    }
cerr<<"mxs = "<<mxs<<endl;
    
    for (int m = 1; m <= M; ++m) {
      const int ans = lower_bound(mxs.begin(), mxs.end(), m) - mxs.begin();
      printf("%d\n", ans);
    }
  }
  return 0;
}
0