結果

問題 No.130 XOR Minimax
ユーザー mkawa2mkawa2
提出日時 2020-01-21 12:14:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 353 ms / 5,000 ms
コード長 1,110 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 11,064 KB
実行使用メモリ 22,008 KB
最終ジャッジ日時 2023-10-10 00:26:37
合計ジャッジ時間 5,055 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
14,576 KB
testcase_01 AC 20 ms
8,640 KB
testcase_02 AC 21 ms
8,812 KB
testcase_03 AC 20 ms
8,644 KB
testcase_04 AC 38 ms
10,464 KB
testcase_05 AC 57 ms
19,556 KB
testcase_06 AC 353 ms
22,008 KB
testcase_07 AC 291 ms
21,600 KB
testcase_08 AC 259 ms
21,784 KB
testcase_09 AC 68 ms
10,804 KB
testcase_10 AC 97 ms
13,460 KB
testcase_11 AC 254 ms
17,572 KB
testcase_12 AC 45 ms
10,060 KB
testcase_13 AC 215 ms
16,224 KB
testcase_14 AC 274 ms
20,884 KB
testcase_15 AC 23 ms
8,768 KB
testcase_16 AC 189 ms
15,332 KB
testcase_17 AC 196 ms
15,408 KB
testcase_18 AC 210 ms
16,260 KB
testcase_19 AC 251 ms
17,172 KB
testcase_20 AC 122 ms
15,304 KB
testcase_21 AC 271 ms
20,884 KB
testcase_22 AC 63 ms
11,008 KB
testcase_23 AC 32 ms
9,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]

def main():
    def dfs(l, r, d=31):
        if r - l == 1: return 0
        for i, a in enumerate(aa[l:r], l):
            if a >> d & 1:
                m = i
                break
        else:
            m = l
        if m == l:
            return dfs(l, r, d - 1)
        return (1 << d) + min(dfs(l, m, d - 1), dfs(m, r, d - 1))

    n = II()
    aa = list(set(LI()))
    aa.sort()
    print(dfs(0, len(aa)))

main()
0