結果

問題 No.1304 あなたは基本が何か知っていますか?私は知っています.
コンテスト
ユーザー t33f
提出日時 2020-12-04 22:15:44
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 30 ms / 2,000 ms
+ 563µs
コード長 897 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 376 ms
コンパイル使用メモリ 92,448 KB
実行使用メモリ 20,072 KB
最終ジャッジ日時 2026-07-12 18:14:13
合計ジャッジ時間 9,608 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 44 WA * 10 RE * 10 TLE * 1 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <vector>
#include <iostream>
using namespace std;
long long dp[1024][1024][2];
long long dps[1024][2];
int main() {
    int n, k, x, y; cin >> n >> k >> x >> y;
    vector<bool> a(1024, false);
    for (int i = 0; i < k; i++) { int b; cin >> b; a[b] = true; }
    constexpr int M = 998244353;
    int cur = 0, prev = 1;
    for (int i = 0; i < 1024; i++)
        if (a[i]) dp[i][i][prev] = dps[i][prev] = 1;
    for (int l = 1; l < n; l++) {
        for (int i = 0; i < 1024; i++) {
            long long sum = 0;
            for (int j = 0; j < 1024; j++) {
                if (a[j]) dp[i][j][cur] = (dps[i^j][prev] - dp[i^j][j][prev]) % M;
                sum += dp[i][j][cur];
            }
            dps[i][cur] = sum % M;
        }
        swap(cur, prev);
    }
    long long ans = 0;
    for (int i = x; i <= y; i++) ans += dps[i][prev];
    cout << (ans % M + M) % M << endl;
}
0