結果
問題 |
No.2442 線形写像
|
ユーザー |
![]() |
提出日時 | 2025-03-26 15:43:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 179 ms / 2,000 ms |
コード長 | 1,049 bytes |
コンパイル時間 | 305 ms |
コンパイル使用メモリ | 82,108 KB |
実行使用メモリ | 109,316 KB |
最終ジャッジ日時 | 2025-03-26 15:43:59 |
合計ジャッジ時間 | 3,225 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
def main():import sysinput = sys.stdin.read().split()ptr = 0N = int(input[ptr])ptr +=1size = 1 << NA = []for _ in range(size):A.append(int(input[ptr]))ptr +=1if N ==0:if A[0] ==0:print("Yes")else:print("No")return# Build the basisbasis = []for x in range(size):current = xfor b in basis:current = min(current, current ^ b)if current !=0:basis.append(current)# Sort in descending order to maintain highest bit firstbasis.sort(reverse=True)# Check each elementis_good = Truefor x in range(size):current_x = xxor_sum = 0for b in basis:if current_x & b:xor_sum ^= A[b]current_x ^= bif current_x !=0 or xor_sum != A[x]:is_good = Falsebreakprint("Yes" if is_good else "No")if __name__ == "__main__":main()