結果
問題 | No.943 取り調べ |
ユーザー | tanon710 |
提出日時 | 2020-05-04 22:06:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 635 ms / 1,206 ms |
コード長 | 842 bytes |
コンパイル時間 | 327 ms |
コンパイル使用メモリ | 87,112 KB |
実行使用メモリ | 78,152 KB |
最終ジャッジ日時 | 2023-09-07 06:31:55 |
合計ジャッジ時間 | 6,373 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
71,336 KB |
testcase_01 | AC | 73 ms
71,564 KB |
testcase_02 | AC | 73 ms
71,156 KB |
testcase_03 | AC | 70 ms
71,240 KB |
testcase_04 | AC | 389 ms
77,332 KB |
testcase_05 | AC | 633 ms
77,228 KB |
testcase_06 | AC | 635 ms
77,100 KB |
testcase_07 | AC | 72 ms
71,404 KB |
testcase_08 | AC | 379 ms
77,084 KB |
testcase_09 | AC | 189 ms
77,268 KB |
testcase_10 | AC | 197 ms
77,676 KB |
testcase_11 | AC | 153 ms
77,336 KB |
testcase_12 | AC | 73 ms
71,260 KB |
testcase_13 | AC | 91 ms
76,684 KB |
testcase_14 | AC | 96 ms
76,780 KB |
testcase_15 | AC | 77 ms
76,376 KB |
testcase_16 | AC | 71 ms
71,272 KB |
testcase_17 | AC | 189 ms
78,152 KB |
testcase_18 | AC | 72 ms
71,332 KB |
testcase_19 | AC | 90 ms
76,740 KB |
testcase_20 | AC | 75 ms
71,576 KB |
testcase_21 | AC | 73 ms
71,072 KB |
testcase_22 | AC | 180 ms
77,456 KB |
testcase_23 | AC | 466 ms
77,268 KB |
ソースコード
n=int(input()) check=[list(map(int,input().split())) for _ in range(n)] for i in range(n): tmp=0 for j in range(n): if check[i][j]==1: tmp+=2**(n-1-j) check[i]=tmp cost=list(map(int,input().split())) ans=10**18 for i in range(0,2**n): flag=format(i,'b') s=set() tmp=i for j in range(n): if (i>>j)&1: s.add(n-1-j) prev=len(s) for _ in range(n): if len(s)==n: break for j in range(n): if j in s: continue if (~tmp)&check[j]==0: s.add(j) tmp+=2**(n-1-j) if len(s)==prev: break prev=len(s) if len(s)==n: tmp=0 for j in range(n): if (i>>j)&1: tmp+=cost[n-1-j] ans=min(ans,tmp) print(ans)