結果
| 問題 |
No.183 たのしい排他的論理和(EASY)
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-10-20 01:29:28 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,060 bytes |
| コンパイル時間 | 174 ms |
| コンパイル使用メモリ | 82,300 KB |
| 実行使用メモリ | 848,928 KB |
| 最終ジャッジ日時 | 2025-10-20 01:29:31 |
| 合計ジャッジ時間 | 2,781 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 MLE * 1 -- * 12 |
ソースコード
from collections.abc import Iterable
def accum_dp(xs: Iterable, f, op, e: int, size: int, init: Iterable, *, is_reset=True):
dp = [e] * size
for i, v in init:
dp[i] = v
for x in xs:
pp = [e] * size if is_reset else dp.copy()
dp, pp = pp, dp
for i in range(size):
for p, v in f(i, pp[i], x):
if not (0 <= p < size): continue
dp[p] = op(dp[p], v)
return dp
N = int(input())
A = list(map(int, input().split()))
def next(i, v, x):
# i: 作られる数
# v: 組み合わせ数
# x: xor される整数
return [(i ^ x, v)]
def op(a, b):
return a or b
# dp = accum_dp(A, next, op, 0, 1<<15, [(0, True)], is_reset=False)
# ans = sum(dp)
# print(ans)
def solve():
m = 1 << 15
dp = [[0] * m for _ in range(N+1)]
dp[0][0] = True
for i, a in enumerate(A):
for j in range(m):
if dp[i][j]:
dp[i+1][j] = True
dp[i+1][j ^ a] = True
return sum(dp[N])
ans = solve()
print(ans)
norioc