結果
| 問題 |
No.1304 あなたは基本が何か知っていますか?私は知っています.
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 22:34:36 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 652 ms / 2,000 ms |
| コード長 | 1,390 bytes |
| コンパイル時間 | 261 ms |
| コンパイル使用メモリ | 82,520 KB |
| 実行使用メモリ | 96,916 KB |
| 最終ジャッジ日時 | 2025-06-22 03:10:19 |
| 合計ジャッジ時間 | 8,708 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
| 外部呼び出し有り |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 44 RE * 10 MLE * 1 -- * 19 |
ソースコード
import sys
from collections import defaultdict
def main():
MOD = 998244353
N, K, X, Y = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))
element_to_index = {a: i for i, a in enumerate(A)}
max_xor = 1023 # Based on problem constraints
# Precompute next indices for each element
next_indices = []
for a_prev in A:
indices = []
for idx, a_next in enumerate(A):
if a_next != a_prev:
indices.append(idx)
next_indices.append(indices)
# Initialize DP
dp = [[0] * (max_xor + 1) for _ in range(K)]
for idx in range(K):
a = A[idx]
dp[idx][a] = 1
for _ in range(N - 1):
new_dp = [[0] * (max_xor + 1) for _ in range(K)]
for a_prev_idx in range(K):
for x in range(max_xor + 1):
if dp[a_prev_idx][x] == 0:
continue
for a_next_idx in next_indices[a_prev_idx]:
a_next = A[a_next_idx]
new_x = x ^ a_next
new_dp[a_next_idx][new_x] = (new_dp[a_next_idx][new_x] + dp[a_prev_idx][x]) % MOD
dp = new_dp
result = 0
for idx in range(K):
for x in range(X, Y + 1):
result = (result + dp[idx][x]) % MOD
print(result)
if __name__ == "__main__":
main()
lam6er