結果
| 問題 |
No.519 アイドルユニット
|
| コンテスト | |
| ユーザー |
6soukiti29
|
| 提出日時 | 2017-06-21 19:40:21 |
| 言語 | Nim (2.2.0) |
| 結果 |
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 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 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
6soukiti29