結果

問題 No.1652 XOR Inequalities
ユーザー Kiri8128Kiri8128
提出日時 2021-08-20 23:39:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,449 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 82,188 KB
実行使用メモリ 84,308 KB
最終ジャッジ日時 2024-04-22 08:32:08
合計ジャッジ時間 5,747 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
62,728 KB
testcase_01 AC 43 ms
55,804 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from random import randrange
from time import time
def ra(a, b):
    la = a.bit_length()
    lb = b.bit_length()
    while 1:
        i = randrange(-1, min(la, lb))
        c = a ^ b if i < 0 else a ^ b ^ (1 << i) ^ randrange(1 << i)
        if chk(a, b, c):
            return c
    
    
def chk(a, b, c):
    if a ^ b <= c and b ^ c <= a and c ^ a <= b: return 1
    return 0

N = int(input())
NN = 1 << N
A = [int(a) for a in input().split()]
if A[0] < 0: A[0] = 0
if N == 1:
    if A[1] < 0: A[1] = 0
    print("Yes")
    print(*A)
    exit()

ng = 0
B = [max(a, 0) for a in A]
for i in range(NN):
    for j in range(NN):
        if B[i] ^ B[j] > B[i^j]:
            if A[i] >= 0 and A[j] >= 0 and A[i^j] >= 0:
                print("No")
                exit()
            ng += 1

sTime = time()
while ng and time() - sTime < 1.5:
    i = randrange(NN)
    if A[i] >= 0: continue
    j = 0
    while j == 0 or i == j:
        j = randrange(NN)
    c = ra(B[j], B[i^j])
    while 1:
        pre = 0
        new = 0
        for j in range(NN):
            if chk(c, B[j], B[i^j]) == 0:
                new += 10000 if A[j] >= 0 and A[i^j] >= 0 else 1
            if chk(B[i], B[j], B[i^j]) == 0:
                pre += 10000 if A[j] >= 0 and A[i^j] >= 0 else 1
        if new <= pre + 1:
            B[i] = c
            ng += new - pre
            break
        c = ra(B[j], B[i^j])

if ng:
    print("No")
else:
    print("Yes")
    print(*B)
0