結果
問題 | No.2669 Generalized Hitting Set |
ユーザー | 👑 Nachia |
提出日時 | 2024-03-08 23:23:10 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,369 ms / 4,000 ms |
コード長 | 2,885 bytes |
コンパイル時間 | 1,124 ms |
コンパイル使用メモリ | 102,504 KB |
実行使用メモリ | 136,656 KB |
最終ジャッジ日時 | 2024-09-29 20:43:00 |
合計ジャッジ時間 | 16,521 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,820 KB |
testcase_03 | AC | 18 ms
6,816 KB |
testcase_04 | AC | 16 ms
6,816 KB |
testcase_05 | AC | 15 ms
6,820 KB |
testcase_06 | AC | 30 ms
6,816 KB |
testcase_07 | AC | 6 ms
6,816 KB |
testcase_08 | AC | 8 ms
6,820 KB |
testcase_09 | AC | 17 ms
6,816 KB |
testcase_10 | AC | 14 ms
6,816 KB |
testcase_11 | AC | 7 ms
6,816 KB |
testcase_12 | AC | 23 ms
6,816 KB |
testcase_13 | AC | 1,216 ms
134,256 KB |
testcase_14 | AC | 108 ms
19,584 KB |
testcase_15 | AC | 3 ms
6,820 KB |
testcase_16 | AC | 28 ms
7,244 KB |
testcase_17 | AC | 113 ms
19,584 KB |
testcase_18 | AC | 2 ms
6,816 KB |
testcase_19 | AC | 15 ms
6,816 KB |
testcase_20 | AC | 2 ms
6,816 KB |
testcase_21 | AC | 29 ms
7,172 KB |
testcase_22 | AC | 8 ms
6,820 KB |
testcase_23 | AC | 68 ms
6,816 KB |
testcase_24 | AC | 35 ms
6,820 KB |
testcase_25 | AC | 72 ms
9,176 KB |
testcase_26 | AC | 1,233 ms
134,632 KB |
testcase_27 | AC | 30 ms
6,816 KB |
testcase_28 | AC | 1,369 ms
136,656 KB |
testcase_29 | AC | 1,348 ms
136,620 KB |
testcase_30 | AC | 1,328 ms
136,580 KB |
testcase_31 | AC | 1,333 ms
136,520 KB |
testcase_32 | AC | 1,264 ms
136,608 KB |
testcase_33 | AC | 57 ms
6,912 KB |
testcase_34 | AC | 38 ms
6,820 KB |
testcase_35 | AC | 310 ms
37,528 KB |
testcase_36 | AC | 2 ms
6,816 KB |
testcase_37 | AC | 57 ms
11,248 KB |
testcase_38 | AC | 5 ms
6,816 KB |
testcase_39 | AC | 1,272 ms
136,652 KB |
testcase_40 | AC | 1,276 ms
136,556 KB |
ソースコード
#ifdef NACHIA #define _GLIBCXX_DEBUG #else #define NDEBUG #endif #include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <queue> #include <array> #include <cmath> #include <atcoder/modint> using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(i64 i=0; i<(i64)(n); i++) #define repr(i,n) for(i64 i=(i64)(n)-1; i>=0; i--) const i64 INF = 1001001001001001001; const char* yn(bool x){ return x ? "Yes" : "No"; } template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; } template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; } template<typename A> using nega_queue = std::priority_queue<A,std::vector<A>,std::greater<A>>; using Modint = atcoder::static_modint<998244353>; using namespace std; namespace nachia{ int Popcount(unsigned long long c) noexcept { #ifdef __GNUC__ return __builtin_popcountll(c); #else c = (c & (~0ull/3)) + ((c >> 1) & (~0ull/3)); c = (c & (~0ull/5)) + ((c >> 2) & (~0ull/5)); c = (c & (~0ull/17)) + ((c >> 4) & (~0ull/17)); c = (c * (~0ull/257)) >> 56; return c; #endif } // please ensure x != 0 int MsbIndex(unsigned long long x) noexcept { #ifdef __GNUC__ return 63 - __builtin_clzll(x); #else using u64 = unsigned long long; int q = (x >> 32) ? 32 : 0; auto m = x >> q; constexpr u64 hi = 0x8888'8888; constexpr u64 mi = 0x1111'1111; m = (((m | ~(hi - (m & ~hi))) & hi) * mi) >> 35; m = (((m | ~(hi - (x & ~hi))) & hi) * mi) >> 31; q += (m & 0xf) << 2; q += 0x3333'3333'2222'1100 >> (((x >> q) & 0xf) << 2) & 0xf; return q; #endif } // please ensure x != 0 int LsbIndex(unsigned long long x) noexcept { #ifdef __GNUC__ return __builtin_ctzll(x); #else return MsbIndex(x & -x); #endif } } void testcase(){ i64 N, M, K; cin >> N >> M >> K; vector<i64> A(1<<N); rep(i,M){ string s; cin >> s; i64 q = 0; rep(i,N) if(s[i] == '1') q |= 1 << i; A[q]++; } rep(d,N) rep(i,1<<N) if(!((i>>d)&1)) A[i] += A[i|1<<d]; vector<vector<i64>> C(N+1); rep(i,N+1) C[i].assign(i+1, 1); for(i64 n=1; n<=N; n++) for(i64 k=1; k<n; k++) C[n][k] = C[n-1][k-1] + C[n-1][k]; rep(i,1<<N){ i64 x = nachia::Popcount(i); if(x < K){ A[i] = 0; continue; } if((x - K) % 2 == 1) A[i] = -A[i]; A[i] *= C[x-1][K-1]; } rep(d,N) rep(i,1<<N) if(!((i>>d)&1)) A[i|1<<d] += A[i]; vector<i64> Q(N+1); rep(i,1<<N){ i64 x = nachia::Popcount(i); chmax(Q[x], A[i]); } vector<i64> ans(M+1, N); rep(i,N+1) chmin(ans[Q[i]], i); repr(i,M) chmin(ans[i], ans[i+1]); rep(i,M) cout << ans[i+1] << '\n'; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); #ifdef NACHIA int T; cin >> T; for(int t=0; t<T; T!=++t?(cout<<'\n'),0:0) #endif testcase(); return 0; }