結果
問題 | No.519 アイドルユニット |
ユーザー |
![]() |
提出日時 | 2017-06-21 19:40:21 |
言語 | Nim (2.0.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,826 bytes |
コンパイル時間 | 3,859 ms |
コンパイル使用メモリ | 66,432 KB |
実行使用メモリ | 276,608 KB |
最終ジャッジ日時 | 2024-06-30 01:27:27 |
合計ジャッジ時間 | 8,534 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
ソースコード
import sequtils,strutils,algorithm proc powInt(n : int64, m : int64, k = 1_000_000_007):int64 = if m == 0: return 1 elif m == 1: return (n mod k) if (m mod 2) == 0: return powInt((n*n) mod k,m div 2, k) mod k else: return (powInt((n*n) mod k,m div 2, k) * n) mod k proc IToS(i : int):string = return $ i proc CToI(c : char): int = return int(c) - int('0') proc BinSToInt(s : string):int = var s2 : string if s[0..1] == "0b": s2 = s[2..<s.len] else: s2 = s var ans = 0 for index,item in s2: ans += (item.CToI * powInt(2,s2.len - 1 - index).int) return ans let n = readline(stdin).parseInt var ans = 0 i,j,num,r,l : int s = newSeq[int](n) A = repeat(s,n) B = newSeqWith(n div 2,newSeq[int](0)) Blist = newSeq[int](0) for i in 0..<n: A[i] = readline(stdin).split.map(parseInt) var S = newSeq[int](powInt(2,n + 1)) for i in countup(2,n,2): s = repeat(0, n - i) & repeat(1, i) var flag = true while flag : num = ("0b" & s.join()).BinSToInt r = -1 l = -1 for index,item in s: if item == 1 and l == -1: l = index elif item == 1: r = index if i == 2: S[num] = A[l][r] B[0].add(num) else: var Max_sum = 0 for b in B[(i div 2) - 2]: if (b and num) == b: j = (b xor num) var i2 = S[j] if Max_sum < i2 + S[b]: Max_sum = i2 + S[b] S[num] = Max_sum if i == n and Max_sum > ans: ans = Max_sum elif i != n: B[(i div 2) - 1].add(num) flag = s.nextPermutation() echo ans