結果

問題 No.130 XOR Minimax
ユーザー 6soukiti296soukiti29
提出日時 2017-09-06 18:17:05
言語 Nim
(2.0.2)
結果
AC  
実行時間 100 ms / 5,000 ms
コード長 575 bytes
コンパイル時間 4,303 ms
コンパイル使用メモリ 68,604 KB
実行使用メモリ 27,588 KB
最終ジャッジ日時 2023-10-10 00:20:14
合計ジャッジ時間 6,583 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
8,760 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 63 ms
17,516 KB
testcase_05 AC 82 ms
23,960 KB
testcase_06 AC 93 ms
27,588 KB
testcase_07 AC 100 ms
24,136 KB
testcase_08 AC 79 ms
16,808 KB
testcase_09 AC 16 ms
7,048 KB
testcase_10 AC 23 ms
7,708 KB
testcase_11 AC 72 ms
14,348 KB
testcase_12 AC 9 ms
6,164 KB
testcase_13 AC 62 ms
14,264 KB
testcase_14 AC 72 ms
12,476 KB
testcase_15 AC 2 ms
4,356 KB
testcase_16 AC 51 ms
9,892 KB
testcase_17 AC 53 ms
10,508 KB
testcase_18 AC 58 ms
12,312 KB
testcase_19 AC 68 ms
12,548 KB
testcase_20 AC 32 ms
7,560 KB
testcase_21 AC 70 ms
12,488 KB
testcase_22 AC 16 ms
5,544 KB
testcase_23 AC 6 ms
4,356 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'algorithm' [UnusedImport]
/home/judge/data/code/Main.nim(1, 36) Warning: imported and not used: 'math' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,algorithm,math
var
    N = stdin.readline.parseInt
    A2 = stdin.readline.split.map(parseInt)
    flag : array[100001, bool]

proc solve(d : int, A : openarray[int]) : int =
    if A.len <= 1 or d == -1:
        return 0
    var
        B = newSeqWith(2, newSeq[int](0))
    for a in A:
        B[((a shr d) and 1)].add(a - (1 shl d))
    if B[0].len == 0:
        return solve(d - 1, B[1])
    elif B[1].len == 0:
        return solve(d - 1, B[0])
    else:
        return (1 shl d) + min(solve(d - 1, B[0]), solve(d - 1, B[1]))

echo solve(29, A2)
0