結果

問題 No.1900 Don't be Powers of 2
ユーザー ShirotsumeShirotsume
提出日時 2022-03-22 15:46:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,222 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 82,828 KB
実行使用メモリ 78,472 KB
最終ジャッジ日時 2024-04-18 14:33:53
合計ジャッジ時間 73,834 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,938 ms
78,472 KB
testcase_01 AC 1,940 ms
77,212 KB
testcase_02 AC 1,940 ms
77,736 KB
testcase_03 AC 1,940 ms
77,792 KB
testcase_04 AC 1,941 ms
77,672 KB
testcase_05 AC 1,939 ms
78,348 KB
testcase_06 AC 1,940 ms
77,700 KB
testcase_07 AC 1,941 ms
77,804 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1,941 ms
78,116 KB
testcase_14 AC 1,941 ms
78,108 KB
testcase_15 AC 50 ms
63,672 KB
testcase_16 AC 48 ms
63,000 KB
testcase_17 AC 1,940 ms
77,792 KB
testcase_18 AC 1,940 ms
78,268 KB
testcase_19 AC 1,940 ms
78,252 KB
testcase_20 AC 1,940 ms
78,156 KB
testcase_21 AC 1,940 ms
78,288 KB
testcase_22 AC 1,941 ms
77,544 KB
testcase_23 AC 57 ms
66,356 KB
testcase_24 AC 65 ms
66,808 KB
testcase_25 AC 67 ms
66,408 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 40 ms
54,264 KB
testcase_32 AC 39 ms
54,796 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 1,941 ms
77,464 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 41 ms
54,388 KB
testcase_43 AC 42 ms
54,208 KB
testcase_44 AC 1,941 ms
77,260 KB
権限があれば一括ダウンロードができます

ソースコード

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