結果

問題 No.1296 OR or NOR
ユーザー Kiri8128Kiri8128
提出日時 2020-06-25 23:54:57
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 704 bytes
コンパイル時間 1,508 ms
コンパイル使用メモリ 86,672 KB
実行使用メモリ 103,940 KB
最終ジャッジ日時 2023-09-02 14:18:26
合計ジャッジ時間 9,492 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
71,132 KB
testcase_01 AC 82 ms
71,312 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 177 ms
103,064 KB
testcase_21 AC 170 ms
103,940 KB
testcase_22 AC 158 ms
102,700 KB
testcase_23 AC 169 ms
102,952 KB
testcase_24 AC 167 ms
102,844 KB
testcase_25 AC 170 ms
102,352 KB
testcase_26 AC 179 ms
103,284 KB
testcase_27 AC 179 ms
102,928 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 愚直チェック

def popcnt(n):
    c = (n & 0x55555555) + ((n>>1) & 0x55555555)
    c = (c & 0x33333333) + ((c>>2) & 0x33333333)
    c = (c & 0x0f0f0f0f) + ((c>>4) & 0x0f0f0f0f)
    c = (c & 0x00ff00ff) + ((c>>8) & 0x00ff00ff)
    c = (c & 0x0000ffff) + ((c>>16) & 0x0000ffff)
    return c

N = int(input())
if N > 20: print(1 // 0)
A = [int(a) for a in input().split()]
S = {}
m = (1 << 60) - 1
for i in range(1 << N):
    s = 0
    for j, a in enumerate(A):
        s |= a
        if i >> j & 1:
            s ^= m
    if s in S:
        S[s] = min(S[s], popcnt(i))
    else:
        S[s] = popcnt(i)

Q = int(input())
for a in [int(a) for a in input().split()]:
    print(S[a] if a in S else -1)
0