結果

問題 No.1900 Don't be Powers of 2
ユーザー Shirotsume
提出日時 2022-03-22 15:46:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,222 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 82,228 KB
実行使用メモリ 78,460 KB
最終ジャッジ日時 2024-10-10 07:48:09
合計ジャッジ時間 73,879 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import time
import random
#https://qiita.com/zawawahoge/items/8bbd4c2319e7f7746266
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

t1 = time.time()
n = int(input())
a = list(map(int,input().split()))
b = []
ans = 1
while time.time() - t1 < 1.9:
    if len(b) == 0 or (random.random() < 0.95 and time.time() - t1 < 1.5):
        if len(a) == 0: break
        now = random.choice(a)
        flag = True
        for v in b:
            if Popcount(v ^ now) == 1:
                flag = False
        if flag:
            a.remove(now)
            b.append(now)
    else:
        now = random.choice(b)
        b.remove(now)
        a.append(now)
    ans = max(ans, len(b))
print(ans)
0