結果

問題 No.1900 Don't be Powers of 2
ユーザー ShirotsumeShirotsume
提出日時 2022-03-22 15:42:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,191 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 78,720 KB
最終ジャッジ日時 2024-04-18 14:30:26
合計ジャッジ時間 74,378 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,939 ms
77,260 KB
testcase_01 AC 1,943 ms
76,800 KB
testcase_02 AC 1,942 ms
77,240 KB
testcase_03 AC 1,940 ms
77,612 KB
testcase_04 AC 1,940 ms
77,932 KB
testcase_05 AC 1,939 ms
77,448 KB
testcase_06 AC 1,940 ms
77,548 KB
testcase_07 AC 1,938 ms
78,516 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1,945 ms
78,132 KB
testcase_14 AC 1,946 ms
77,928 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 1,943 ms
78,408 KB
testcase_18 AC 1,942 ms
77,568 KB
testcase_19 AC 1,940 ms
77,576 KB
testcase_20 AC 1,943 ms
77,376 KB
testcase_21 AC 1,939 ms
78,172 KB
testcase_22 AC 1,939 ms
77,764 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 RE -
testcase_32 RE -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 RE -
testcase_43 RE -
testcase_44 AC 1,942 ms
77,096 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.8 and time.time() - t1 < 1.5):
        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