結果
問題 |
No.1900 Don't be Powers of 2
|
ユーザー |
|
提出日時 | 2022-03-22 15:42:11 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,191 bytes |
コンパイル時間 | 202 ms |
コンパイル使用メモリ | 82,296 KB |
実行使用メモリ | 78,892 KB |
最終ジャッジ日時 | 2024-10-10 07:44:40 |
合計ジャッジ時間 | 74,773 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 19 RE * 9 |
ソースコード
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)