結果
| 問題 |
No.698 ペアでチームを作ろう
|
| ユーザー |
ikd
|
| 提出日時 | 2018-07-15 19:27:10 |
| 言語 | Nim (2.2.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 1,000 ms |
| コード長 | 550 bytes |
| コンパイル時間 | 3,381 ms |
| コンパイル使用メモリ | 65,900 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-01 03:11:41 |
| 合計ジャッジ時間 | 4,020 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 39) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated] /home/judge/data/code/Main.nim(1, 39) Warning: imported and not used: 'future' [UnusedImport]
ソースコード
import strutils, sequtils, algorithm, future
var
n=stdin.readLine.parseInt
a=stdin.readLine.split.map(parseInt)
memo=newSeq[int](1 shl n)
fill(memo, -1) # algorithm
proc f(bit: int): int=
if memo[bit]>=0:
return memo[bit]
elif bit==(1 shl n)-1:
return 0
else:
for i in 0..<n:
if (bit and (1 shl i))>0:
continue
for j in 0..<i:
if (bit and (1 shl j))>0:
continue
memo[bit]=max(memo[bit], (a[i] xor a[j])+f(bit xor (1 shl i) xor (1 shl j)))
return memo[bit]
echo f(0)
ikd