結果
問題 | No.130 XOR Minimax |
ユーザー |
![]() |
提出日時 | 2017-09-06 18:16:09 |
言語 | Nim (2.2.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 574 bytes |
コンパイル時間 | 2,908 ms |
コンパイル使用メモリ | 65,792 KB |
実行使用メモリ | 38,212 KB |
最終ジャッジ日時 | 2024-06-30 03:09:12 |
合計ジャッジ時間 | 4,392 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 19 WA * 2 |
コンパイルメッセージ
/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]
ソースコード
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)