結果
問題 | No.2669 Generalized Hitting Set |
ユーザー | chineristAC |
提出日時 | 2024-01-24 22:28:32 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,400 ms / 4,000 ms |
コード長 | 3,919 bytes |
コンパイル時間 | 10,595 ms |
コンパイル使用メモリ | 296,936 KB |
実行使用メモリ | 102,248 KB |
最終ジャッジ日時 | 2024-09-28 07:09:46 |
合計ジャッジ時間 | 28,951 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,812 KB |
testcase_01 | AC | 3 ms
6,816 KB |
testcase_02 | AC | 3 ms
6,940 KB |
testcase_03 | AC | 183 ms
6,944 KB |
testcase_04 | AC | 157 ms
6,940 KB |
testcase_05 | AC | 134 ms
6,944 KB |
testcase_06 | AC | 239 ms
12,864 KB |
testcase_07 | AC | 37 ms
6,944 KB |
testcase_08 | AC | 56 ms
6,940 KB |
testcase_09 | AC | 170 ms
13,456 KB |
testcase_10 | AC | 91 ms
8,168 KB |
testcase_11 | AC | 41 ms
6,944 KB |
testcase_12 | AC | 215 ms
12,788 KB |
testcase_13 | AC | 919 ms
69,344 KB |
testcase_14 | AC | 90 ms
11,932 KB |
testcase_15 | AC | 3 ms
6,940 KB |
testcase_16 | AC | 24 ms
6,944 KB |
testcase_17 | AC | 91 ms
12,084 KB |
testcase_18 | AC | 3 ms
6,940 KB |
testcase_19 | AC | 13 ms
6,940 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 24 ms
6,944 KB |
testcase_22 | AC | 7 ms
6,944 KB |
testcase_23 | AC | 383 ms
37,160 KB |
testcase_24 | AC | 247 ms
20,996 KB |
testcase_25 | AC | 359 ms
38,800 KB |
testcase_26 | AC | 957 ms
77,540 KB |
testcase_27 | AC | 186 ms
20,840 KB |
testcase_28 | AC | 1,372 ms
102,116 KB |
testcase_29 | AC | 1,400 ms
102,248 KB |
testcase_30 | AC | 1,385 ms
102,240 KB |
testcase_31 | AC | 1,393 ms
102,248 KB |
testcase_32 | AC | 1,334 ms
102,240 KB |
testcase_33 | AC | 332 ms
37,732 KB |
testcase_34 | AC | 317 ms
20,236 KB |
testcase_35 | AC | 522 ms
53,088 KB |
testcase_36 | AC | 2 ms
5,376 KB |
testcase_37 | AC | 46 ms
7,808 KB |
testcase_38 | AC | 4 ms
5,376 KB |
testcase_39 | AC | 1,328 ms
102,244 KB |
testcase_40 | AC | 1,313 ms
102,244 KB |
ソースコード
// -fsanitize=undefined, //#define _GLIBCXX_DEBUG #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <iostream> #include <vector> #include <string> #include <map> #include <set> #include <queue> #include <algorithm> #include <cmath> #include <iomanip> #include <random> #include <stdio.h> #include <fstream> #include <functional> #include <cassert> #include <unordered_map> #include <bitset> #include <chrono> #include <atcoder/modint> #include "testlib.h" using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i=0;i<n;i+=1) #define rrep(i,n) for (int i=n-1;i>-1;i--) #define pb push_back #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << " )\n"; template<class T> using vec = vector<T>; template<class T> using vvec = vec<vec<T>>; template<class T> using vvvec = vec<vvec<T>>; using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; template<class T> bool chmin(T &a, T b){ if (a>b){ a = b; return true; } return false; } template<class T> bool chmax(T &a, T b){ if (a<b){ a = b; return true; } return false; } template<class T> T sum(vec<T> x){ T res=0; for (auto e:x){ res += e; } return res; } template<class T> void printv(vec<T> x){ for (auto e:x){ cout<<e<<" "; } cout<<endl; } template<class T,class U> ostream& operator<<(ostream& os, const pair<T,U>& A){ os << "(" << A.first <<", " << A.second << ")"; return os; } ostream& operator<<(ostream& os, const mint& a){ os << a.val(); return os; } template<class T> ostream& operator<<(ostream& os, const set<T>& S){ os << "set{"; for (auto a:S){ os << a; auto it = S.find(a); it++; if (it!=S.end()){ os << ", "; } } os << "}"; return os; } template<class T> ostream& operator<<(ostream& os, const vec<T>& A){ os << "["; rep(i,A.size()){ os << A[i]; if (i!=A.size()-1){ os << ", "; } } os << "]" ; return os; } const int M = 10000; mint fact[M],finv[M],inverse[M]; void init_mint(){ fact[0] = 1, fact[1] = 1; finv[0] = 1, finv[1] = 1; inverse[0] = 0, inverse[1] = 1; for (int n=2;n<M;n++){ fact[n] = fact[n-1] * n; inverse[n] = (-inverse[998244353 % n]) * (998244353/n); finv[n] = finv[n-1] * inverse[n]; } } mint comb(int n,int r){ if (r==-1 && n==-1) return 1; if (r < 0 || n < r) return 0; return fact[n] * finv[r] * finv[n-r]; } const int MIN_n = 1; const int MAX_n = 24; const int MIN_m = 1; const int MAX_m = 300'000; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); init_mint(); registerValidation(); int n = inf.readInt(MIN_n,MAX_n); inf.readSpace(); int m = inf.readInt(MIN_m,MAX_m); inf.readSpace(); int k = inf.readInt(1,n); inf.readEoln(); string mok = "[0-1]{"; mok += to_string(n); mok += ","; mok += to_string(n); mok += "}"; vec<mint> cnt(1<<n,0); rep(i,m){ string S = inf.readToken(mok); inf.readEoln(); int val = 0, S_popcnt = 0; rep(j,n){ val = (val<<1) + (S[j] - '0'); S_popcnt += S[j] - '0'; } ensure(k <= S_popcnt); cnt[val]++; } inf.readEof(); vec<mint> f(n+1,0); f[k] = 1; for (int i=k+1;i<=n;i++){ f[i] = 1; for (int j=k;j<i;j++){ f[i] -= comb(i,j) * f[j]; } } for (int i=0;i<n;i++){ int t = 1<<i; for (int S = 0;S < (1<<n);S++){ if (S & t) cnt[S^t] += cnt[S]; } } for (int S = 0;S < (1<<n);S++){ cnt[S] *= f[__builtin_popcount(S)]; } for (int i=0;i<n;i++){ int t = 1<<i; for (int S = 0;S < (1<<n);S++){ if (S & t) cnt[S] += cnt[S^t]; } } vec<int> g(m+1,n+1); rep(S,1<<n){ int p = cnt[S].val(); chmin(g[p],__builtin_popcount(S)); } for (int i=m-1;0<=i;i--){ g[i] = min(g[i],g[i+1]); } for (int i=1;i<=m;i++){ cout << g[i] << "\n"; } }