結果

問題 No.130 XOR Minimax
ユーザー 6soukiti296soukiti29
提出日時 2017-09-05 22:50:09
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 766 bytes
コンパイル時間 3,262 ms
コンパイル使用メモリ 69,036 KB
実行使用メモリ 17,772 KB
最終ジャッジ日時 2023-09-12 15:06:35
合計ジャッジ時間 5,795 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 20 ms
12,204 KB
testcase_05 AC 32 ms
14,104 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,strutils,algorithm
var
    N = stdin.readline.parseInt
    A2 = stdin.readline.split.map(parseInt)
    flag : array[100001, bool]
A2.sort(system.cmp)
flag[0] = true
var A = newSeq[int](0)
for i,a in A2:
    if i == 0:
        A.add(a)
        continue
    if a != A2[i - 1]:
        A.add(a)
var
    p,k : int
    ans : int
block tansaku:
    for i in countdown(29, 0):
        var f : bool
        for j in 1..<A.len:
            if ((1 shl i) and A[j]) != ((1 shl i) and A[j - 1]):
                if flag[j - 1]:
                    p = j - 1
                    k = i
                    ans += (1 shl i)
                    break tansaku
                f = true
                flag[j] = true
        if f:
            ans += (1 shl i)
echo ans
0