結果
問題 | No.1304 あなたは基本が何か知っていますか?私は知っています. |
ユーザー |
![]() |
提出日時 | 2025-03-31 17:32:07 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,294 bytes |
コンパイル時間 | 163 ms |
コンパイル使用メモリ | 82,172 KB |
実行使用メモリ | 167,280 KB |
最終ジャッジ日時 | 2025-03-31 17:33:14 |
合計ジャッジ時間 | 7,852 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 TLE * 1 -- * 53 |
ソースコード
import sysfrom collections import defaultdictMOD = 998244353def main():input = sys.stdin.read().split()idx = 0N = int(input[idx]); idx +=1K = int(input[idx]); idx +=1X = int(input[idx]); idx +=1Y = int(input[idx]); idx +=1A = list(map(int, input[idx:idx+K]))# Initial state: after first element# state is a dict where key is prev element, value is a dict of {xor_val: count}current = defaultdict(dict)for a in A:if a not in current:current[a] = defaultdict(int)current[a][a] = 1for _ in range(N - 1):next_state = defaultdict(lambda: defaultdict(int))for prev_val in current:for xor_val in current[prev_val]:cnt = current[prev_val][xor_val]for a in A:if a == prev_val:continuenew_xor = xor_val ^ anext_state[a][new_xor] = (next_state[a][new_xor] + cnt) % MODcurrent = next_statetotal = 0for a in current:xor_dict = current[a]for x in range(X, Y + 1):if x in xor_dict:total = (total + xor_dict[x]) % MODprint(total % MOD)if __name__ == "__main__":main()