結果
問題 | No.2669 Generalized Hitting Set |
ユーザー |
|
提出日時 | 2024-01-24 22:28:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 3,919 bytes |
コンパイル時間 | 2,932 ms |
コンパイル使用メモリ | 191,956 KB |
最終ジャッジ日時 | 2025-02-18 22:34:19 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
In file included from /usr/include/c++/13/string:43, from /usr/include/c++/13/bits/locale_classes.h:40, from /usr/include/c++/13/bits/ios_base.h:41, from /usr/include/c++/13/ios:44, from /usr/include/c++/13/ostream:40, from /usr/include/c++/13/iostream:41, from main.cpp:9: /usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<char, std::allocator<char> >::_Vector_impl::~_Vector_impl()’: /usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]’: target specific option mismatch 184 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/13/vector:66, from main.cpp:10: /usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here 133 | struct _Vector_impl | ^~~~~~~~~~~~
ソースコード
// -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"; } }