結果
問題 | No.1304 あなたは基本が何か知っていますか?私は知っています. |
ユーザー |
![]() |
提出日時 | 2021-02-01 03:42:20 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,427 bytes |
コンパイル時間 | 1,826 ms |
コンパイル使用メモリ | 176,440 KB |
実行使用メモリ | 281,824 KB |
最終ジャッジ日時 | 2024-06-12 16:37:33 |
合計ジャッジ時間 | 13,371 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 33 WA * 32 RE * 9 |
ソースコード
#include <bits/stdc++.h>#pragma GCC target("avx")#pragma GCC optimize("O3")#pragma GCC optimize("unroll-loops")using namespace std;#define ll long long#define rep(i, m, n) for (ll i = m; i < n; i++)#define mod 998244353void fwt(vector<ll>& f) {int n = f.size();for(int i = 1; i < n; i <<= 1) {for(int j = 0; j < n; j++) {if((j & i) == 0) {ll x = f[j], y = f[j | i];f[j] = x + y, f[j | i] = x - y;}}}}void ifwt(vector<ll>& f) {int n = f.size();for(int i = 1; i < n; i <<= 1) {for(int j = 0; j < n; j++) {if((j & i) == 0) {ll x = f[j], y = f[j | i];f[j] = (x + y) / 2, f[j | i] = (x - y) / 2;}}}}int main(){cin.tie(nullptr);ios::sync_with_stdio(false);ll N, K, X, Y;cin >> N >> K >> X >> Y;ll M = 1048576;vector<vector<ll>> dp(N + 2, vector<ll>(M, 1));vector<ll> H(M);rep(i, 0, K) {ll A;cin >> A;H[A]++;}fwt(H);rep(v, 0, M) dp[1][v] = dp[0][v] * H[v];rep(v, 0, M) dp[2][v] = dp[1][v] * H[v] - K * dp[0][v];rep(i, 3, N + 1) rep(v, 0, M) dp[i][v] = (dp[i - 1][v] * H[v] - (K - 1) * dp[i - 2][v] + 10LL * mod) % mod;vector<ll> ep(M);rep(v, 0, M) ep[v] = dp[N][v];ifwt(ep);ll res=0;rep(v, 0, M) if(X <= v & v <= Y) res = (res + ep[v]) % mod;cout << res % mod << endl;}