結果

問題 No.943 取り調べ
ユーザー face4face4
提出日時 2019-11-14 22:10:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 669 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 14,528 KB
最終ジャッジ日時 2023-10-25 03:28:15
合計ジャッジ時間 7,607 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,108 KB
testcase_01 AC 28 ms
10,108 KB
testcase_02 AC 29 ms
10,108 KB
testcase_03 AC 29 ms
10,108 KB
testcase_04 TLE -
testcase_05 AC 1,146 ms
10,108 KB
testcase_06 AC 1,177 ms
10,108 KB
testcase_07 AC 28 ms
10,108 KB
testcase_08 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

counton = [0]*n
for i in range(n):
    b = input().split()
    for j in range(n):
            counton[i] += 1<<j if b[j]=="1" else 0

a = list(map(int, input().split()))

ans = sum(a)

for i in range(2**n):
    tmp = 0
    for j in range(n):
        tmp += a[j] if ((i>>j)&1) == 1 else 0
    
    # 高速化出来る
    if tmp >= ans:
        continue

    lie, confess, k = i, 0, -1
    while k+1 < n:
        k += 1
        if ((confess>>k)&1) == 1:
            continue
        if (lie&counton[k]) == counton[k]:
            confess |= 1<<k
            lie |= 1<<k
            k = -1
    
    if confess == (1<<n)-1:
        ans = tmp

print(ans)
0