結果

問題 No.2442 線形写像
ユーザー Nikkuniku029Nikkuniku029
提出日時 2023-08-25 22:09:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 911 bytes
コンパイル時間 449 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 87,372 KB
最終ジャッジ日時 2023-08-25 22:09:18
合計ジャッジ時間 4,050 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,380 KB
testcase_01 AC 69 ms
71,364 KB
testcase_02 AC 70 ms
71,268 KB
testcase_03 AC 68 ms
71,332 KB
testcase_04 WA -
testcase_05 AC 70 ms
71,504 KB
testcase_06 WA -
testcase_07 AC 71 ms
71,336 KB
testcase_08 AC 74 ms
71,096 KB
testcase_09 WA -
testcase_10 AC 86 ms
76,804 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 86 ms
76,788 KB
testcase_14 AC 134 ms
77,660 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 179 ms
78,672 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f  # 8bitごと
    x = x + (x >> 8)  # 16bitごと
    x = x + (x >> 16)  # 32bitごと
    x = x + (x >> 32)  # 64bitごと = 全部の合計
    return x & 0x0000007f


N = int(input())
A = [int(input()) for _ in range(1 << N)]
ans = 'Yes'
if A[0] != 0:
    exit(print('No'))
for i in range(1, 1 << N):
    if popcount(i) > 1:
        tmp = 0
        for j in range(N):
            if i & (1 << j):
                tmp ^= A[j]
        if tmp != A[i]:
            ans = 'No'
print(ans)
0