結果
問題 | No.130 XOR Minimax |
ユーザー |
![]() |
提出日時 | 2017-09-06 18:17:05 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 77 ms / 5,000 ms |
コード長 | 575 bytes |
コンパイル時間 | 3,252 ms |
コンパイル使用メモリ | 65,932 KB |
実行使用メモリ | 39,524 KB |
最終ジャッジ日時 | 2024-09-12 22:49:00 |
合計ジャッジ時間 | 5,019 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
/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,mathvarN = stdin.readline.parseIntA2 = 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 0varB = 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)