結果
問題 | No.911 ラッキーソート |
ユーザー |
![]() |
提出日時 | 2020-03-17 12:18:18 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 145 ms / 2,000 ms |
コード長 | 1,001 bytes |
コンパイル時間 | 87 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 35,300 KB |
最終ジャッジ日時 | 2024-11-30 16:56:36 |
合計ジャッジ時間 | 7,286 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#!/usr/bin/env python3.8# %%import sysread = sys.stdin.buffer.readreadline = sys.stdin.buffer.readlinereadlines = sys.stdin.buffer.readlinesfrom functools import lru_cache# %%N, L, R, *A = map(int, read().split())status = [-1] * 64# %%def calc_bitwise_status():for a, b in zip(A, A[1:]):n = (a ^ b).bit_length() - 1aa = (a >> n) & 1if aa == 0:if status[n] == 1:return Falsestatus[n] = 0else:if status[n] == 0:return Falsestatus[n] = 1return True# %%if not calc_bitwise_status():print(0)exit()# %%@lru_cache(None)def f(N, i):if N < 0:return 0if i == 63:return 1s = status[i]q, r = divmod(N, 2)if s == 0:return f(N // 2, i + 1)elif s == 1:return f((N - 1) // 2, i + 1)else:return f(N // 2, i + 1) + f((N - 1) // 2, i + 1)# %%print(f(R, 0) - f(L - 1, 0))