結果
問題 | No.130 XOR Minimax |
ユーザー | Mao-beta |
提出日時 | 2024-03-15 01:03:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,128 ms / 5,000 ms |
コード長 | 1,759 bytes |
コンパイル時間 | 361 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 456,536 KB |
最終ジャッジ日時 | 2024-03-15 01:03:37 |
合計ジャッジ時間 | 16,148 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 463 ms
226,420 KB |
testcase_01 | AC | 46 ms
57,704 KB |
testcase_02 | AC | 46 ms
57,704 KB |
testcase_03 | AC | 46 ms
57,704 KB |
testcase_04 | AC | 963 ms
409,572 KB |
testcase_05 | AC | 904 ms
456,468 KB |
testcase_06 | AC | 959 ms
456,440 KB |
testcase_07 | AC | 935 ms
456,536 KB |
testcase_08 | AC | 1,058 ms
456,484 KB |
testcase_09 | AC | 185 ms
130,480 KB |
testcase_10 | AC | 274 ms
159,304 KB |
testcase_11 | AC | 851 ms
393,472 KB |
testcase_12 | AC | 104 ms
92,824 KB |
testcase_13 | AC | 703 ms
337,008 KB |
testcase_14 | AC | 1,107 ms
398,500 KB |
testcase_15 | AC | 66 ms
73,092 KB |
testcase_16 | AC | 764 ms
308,692 KB |
testcase_17 | AC | 758 ms
315,428 KB |
testcase_18 | AC | 845 ms
320,064 KB |
testcase_19 | AC | 945 ms
357,092 KB |
testcase_20 | AC | 413 ms
210,896 KB |
testcase_21 | AC | 1,128 ms
395,940 KB |
testcase_22 | AC | 230 ms
139,940 KB |
testcase_23 | AC | 123 ms
96,932 KB |
ソースコード
import sys import math import bisect from heapq import heapify, heappop, heappush from collections import deque, defaultdict, Counter from functools import lru_cache from itertools import accumulate, combinations, permutations, product sys.setrecursionlimit(1000000) MOD = 10 ** 9 + 7 MOD99 = 998244353 input = lambda: sys.stdin.readline().strip() NI = lambda: int(input()) NMI = lambda: map(int, input().split()) NLI = lambda: list(NMI()) SI = lambda: input() SMI = lambda: input().split() SLI = lambda: list(SMI()) EI = lambda m: [NLI() for _ in range(m)] class Node: def __init__(self): self.child = [-1] * 2 class BinaryTrie: def __init__(self, bit=32): self.D = [[-1, -1]] self.bit = bit def add(self, x): now = 0 for i in range(self.bit-1, -1, -1): b = (x>>i) & 1 if self.D[now][b] == -1: self.D[now][b] = len(self.D) now = self.D[now][b] self.D.append([-1, -1]) def dfs(self): ans = 1 << self.bit stack = deque() stack.append([0, 0]) while stack: now, res = stack.pop() l, r = self.D[now] if l == r == -1: ans = min(ans, res) elif l == -1 or r == -1: res <<= 1 if l == -1: stack.append([r, res]) else: stack.append([l, res]) else: res = (res << 1) | 1 stack.append([l, res]) stack.append([r, res]) return ans def main(): N = NI() A = NLI() trie = BinaryTrie() for a in A: trie.add(a) print(trie.dfs()) if __name__ == "__main__": main()