結果
| 問題 |
No.183 たのしい排他的論理和(EASY)
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-10-20 01:11:04 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 760 bytes |
| コンパイル時間 | 2,313 ms |
| コンパイル使用メモリ | 82,480 KB |
| 実行使用メモリ | 276,832 KB |
| 最終ジャッジ日時 | 2025-10-20 01:11:14 |
| 合計ジャッジ時間 | 7,744 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 TLE * 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<<16, [(0, True)], is_reset=False)
ans = sum(dp)
print(ans)
norioc