結果
問題 |
No.2672 Subset Xor Sum
|
ユーザー |
|
提出日時 | 2024-03-13 21:02:51 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 641 bytes |
コンパイル時間 | 210 ms |
コンパイル使用メモリ | 82,364 KB |
実行使用メモリ | 396,752 KB |
最終ジャッジ日時 | 2024-09-29 23:36:29 |
合計ジャッジ時間 | 17,240 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 46 WA * 20 |
ソースコード
#!/usr/bin/python3 # 2 # 1 1 # でYesを返す噓解法 import sys n = int(input()) a = list(map(int, input().split())) xor_s = 0 for i in range(n): xor_s ^= a[i] if xor_s != 0: print("No") sys.exit() if n > 5001: print("Yes") sys.exit() MAX_XOR = 2**13 dp = [[False for j in range(MAX_XOR)] for i in range(n)] dp[1][a[1]] = True # 配るDP for i in range(1, n - 1): dp[i + 1] = dp[i] dp[i + 1][a[i + 1]] = True for j in range(MAX_XOR): if (dp[i][j] == False): continue dp[i + 1][j ^ a[i + 1]] = True if (dp[n - 1][a[0]] == True): print("Yes") else: print("No")