結果

問題 No.130 XOR Minimax
ユーザー 6soukiti296soukiti29
提出日時 2017-09-06 18:16:09
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 574 bytes
コンパイル時間 3,283 ms
コンパイル使用メモリ 68,216 KB
実行使用メモリ 27,800 KB
最終ジャッジ日時 2023-09-12 15:07:47
合計ジャッジ時間 5,346 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
8,792 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 60 ms
17,484 KB
testcase_05 AC 73 ms
24,004 KB
testcase_06 WA -
testcase_07 AC 83 ms
23,980 KB
testcase_08 AC 77 ms
16,900 KB
testcase_09 AC 15 ms
7,076 KB
testcase_10 AC 21 ms
7,596 KB
testcase_11 WA -
testcase_12 AC 9 ms
6,008 KB
testcase_13 AC 55 ms
14,200 KB
testcase_14 AC 71 ms
12,556 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 49 ms
9,836 KB
testcase_17 AC 52 ms
10,548 KB
testcase_18 AC 57 ms
12,488 KB
testcase_19 AC 66 ms
12,572 KB
testcase_20 AC 31 ms
7,456 KB
testcase_21 AC 69 ms
12,736 KB
testcase_22 AC 16 ms
5,608 KB
testcase_23 AC 5 ms
4,380 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 == 0:
        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