結果
| 問題 | 
                            No.1304 あなたは基本が何か知っていますか?私は知っています.
                             | 
                    
| コンテスト | |
| ユーザー | 
                             lam6er
                         | 
                    
| 提出日時 | 2025-04-15 22:28:21 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 985 bytes | 
| コンパイル時間 | 379 ms | 
| コンパイル使用メモリ | 82,604 KB | 
| 実行使用メモリ | 192,312 KB | 
| 最終ジャッジ日時 | 2025-06-22 03:10:03 | 
| 合計ジャッジ時間 | 9,784 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 53 TLE * 1 MLE * 1 -- * 19 | 
ソースコード
import sys
from collections import defaultdict
MOD = 998244353
def main():
    N, K, X, Y = map(int, sys.stdin.readline().split())
    A = list(map(int, sys.stdin.readline().split()))
    
    # Precompute allowed transitions for each element
    allowed = {a: [b for b in A if b != a] for a in A}
    
    # Initialize DP: prev[a] is a dictionary {xor_sum: count}
    prev = defaultdict(lambda: defaultdict(int))
    for a in A:
        prev[a][a] = 1
    
    for _ in range(N - 1):
        curr = defaultdict(lambda: defaultdict(int))
        for a in prev:
            for x in prev[a]:
                cnt = prev[a][x]
                for b in allowed[a]:
                    new_x = x ^ b
                    curr[b][new_x] = (curr[b][new_x] + cnt) % MOD
        prev = curr
    
    result = 0
    for a in prev:
        for x in prev[a]:
            if X <= x <= Y:
                result = (result + prev[a][x]) % MOD
    print(result)
if __name__ == "__main__":
    main()
            
            
            
        
            
lam6er