結果
問題 | No.130 XOR Minimax |
ユーザー | ntuda |
提出日時 | 2022-02-13 10:43:19 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 674 bytes |
コンパイル時間 | 661 ms |
コンパイル使用メモリ | 86,936 KB |
実行使用メモリ | 92,964 KB |
最終ジャッジ日時 | 2023-09-11 15:19:42 |
合計ジャッジ時間 | 5,408 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 93 ms
71,832 KB |
testcase_02 | AC | 93 ms
71,440 KB |
testcase_03 | AC | 96 ms
71,596 KB |
testcase_04 | AC | 112 ms
89,828 KB |
testcase_05 | AC | 121 ms
92,380 KB |
testcase_06 | AC | 175 ms
91,740 KB |
testcase_07 | WA | - |
testcase_08 | AC | 563 ms
92,964 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
ソースコード
from collections import deque from bisect import bisect_left N = int(input()) A = list(map(int, input().split())) amax = max(A) n = amax.bit_length() - 1 q = deque() # target,left,right,value q.append((2 ** n, n, 0, N, 0)) ans = 10 ** 10 while len(q) > 0: (x, i, l, r, v) = q.pop() if i < 0: if ans > v: ans = v continue y = bisect_left(A, x) if y == l: q.append((x + 2 ** (i - 1), i - 1, y, r, v * 2)) elif y == r: q.append((x - 2 ** (i - 1), i - 1, l, y, v * 2)) else: q.append((x + 2 ** (i - 1), i - 1, y, r, v * 2 + 1)) q.append((x - 2 ** (i - 1), i - 1, l, y, v * 2 + 1)) print(ans)